public override void OnPreviewGUI(Rect r, GUIStyle background) { Pose pose = (Pose)target; if (previewSkeleton != null) { var bones = previewSkeleton.GetComponentsInChildren <Bone>(); GL.Begin(GL.LINES); foreach (Bone b in bones) { PositionValue pv = Array.Find(pose.positions, x => x.name == b.name); if (pv != null) { RotationValue rv = Array.Find(pose.rotations, x => x.name == b.name); Vector3 v = pv.position + (rv.rotation * new Vector3(0, 1, 0)) * b.length * 40; GL.Color(new Color(1, 0, 0, 1)); GL.Vertex(pv.position * 40 + (Vector3)r.center); GL.Vertex(v + (Vector3)r.center); } } GL.End(); } //GL.Begin(GL.LINES); //GameObject go = GameObject.Find("orc_3"); //SpriteRenderer sr = go.GetComponent<SpriteRenderer>(); //Texture2D tex = sr.sprite.texture; //Sprite spr = sr.sprite; //Rect source = new Rect(spr.rect.x / tex.width, spr.rect.y / tex.height, spr.rect.width / tex.width, spr.rect.height / tex.height); //GL.Color(Color.red); //GL.Vertex(new Vector3(r.x, r.y, 0)); //GL.Vertex(new Vector3(r.x + r.width, r.y + r.height, 0)); //GL.End(); //Graphics.DrawTexture(r, tex, source, 0, 0, 0, 0, sr.sharedMaterial); }
/// <summary> /// Gets the forward vector of this object at the specified number of seconds in the past. /// </summary> public RotationValue GetForwardVectorAtTime(float timeAgo) { timeAgo = ClampDuration(timeAgo); RotationValue val = new RotationValue(); float counter = 0.0f; for (int i = 0; i < LogBufferSize; ++i) { if (counter >= timeAgo) { int index = GetLogIndex(i); val.Forward = ForwardLogs[index]; val.Right = RightLogs[index]; return(val); } counter += DeltaTimeLogs[GetLogIndex(i)]; } val.Forward = ForwardLogs[GetLogIndex(LogBufferSize - 1)]; val.Right = RightLogs[GetLogIndex(LogBufferSize - 1)]; return(val); }
/// <summary> /// Gets the forward vector of this object at the specified number of seconds in the past. /// </summary> public RotationValue GetForwardVectorAtTime(float timeAgo) { timeAgo = ClampDuration(timeAgo); RotationValue val = new RotationValue(); float counter = 0.0f; for (int i = 0; i < LogBufferSize; ++i) { if (counter >= timeAgo) { int index = GetLogIndex(i); val.Forward = ForwardLogs[index]; val.Right = RightLogs[index]; return val; } counter += DeltaTimeLogs[GetLogIndex(i)]; } val.Forward = ForwardLogs[GetLogIndex(LogBufferSize - 1)]; val.Right = RightLogs[GetLogIndex(LogBufferSize - 1)]; return val; }
public static float LerpValueAtDistance(float distance, RotationValue a, RotationValue b) => LerpValueAtDistance(distance, a, b, math.lerp);
public GridTile(int tileId, GridSides sides, RotationValue rotation) { TileId = tileId; Sides = sides; Rotation = rotation; }
public GameObject PlaceStructureOnTheMap(Vector3 gridPosition, GameObject buildingPrefab, RotationValue rotationValue) { GameObject newStructure = Instantiate(buildingPrefab, ground.position + gridPosition, Quaternion.identity); Vector3 rotation = Vector3.zero; switch (rotationValue) { case RotationValue.R0: break; case RotationValue.R90: rotation = new Vector3(0, 90, 0); break; case RotationValue.R180: rotation = new Vector3(0, 180, 0); break; case RotationValue.R270: rotation = new Vector3(0, 270, 0); break; default: break; } foreach (Transform child in newStructure.transform) { child.Rotate(rotation, Space.World); } return(newStructure); }
//public void CreateBuilding(Vector3 gridPosition, GridStructure grid, GameObject buildingPrefab) //{ // GameObject newStructure = Instantiate(buildingPrefab, ground.position + gridPosition, Quaternion.identity); // grid.PlaceStructureOnTheGrid(newStructure, gridPosition); //} public GameObject CreateGhostStructure(Vector3 gridPosition, GameObject buildingPrefab, RotationValue rotationValue = RotationValue.R0) { GameObject newStructure = PlaceStructureOnTheMap(gridPosition, buildingPrefab, rotationValue); Color colorToSet = Color.green; ModifyStructurePrefabLook(newStructure, colorToSet); return(newStructure); }
public RoadStructureHelper(GameObject roadPrefab, RotationValue roadPrefabRotation) { RoadPrefabRotation = roadPrefabRotation; RoadPrefab = roadPrefab; }
void ReleaseDesignerOutlets() { if (GroupUngroupButton != null) { GroupUngroupButton.Dispose(); GroupUngroupButton = null; } if (RotationSlider != null) { RotationSlider.Dispose(); RotationSlider = null; } if (RotationValue != null) { RotationValue.Dispose(); RotationValue = null; } if (ShapeHeight != null) { ShapeHeight.Dispose(); ShapeHeight = null; } if (ShapeName != null) { ShapeName.Dispose(); ShapeName = null; } if (ShapeType != null) { ShapeType.Dispose(); ShapeType = null; } if (ShapeWidth != null) { ShapeWidth.Dispose(); ShapeWidth = null; } if (ShapeX != null) { ShapeX.Dispose(); ShapeX = null; } if (ShapeY != null) { ShapeY.Dispose(); ShapeY = null; } if (VisibleButton != null) { VisibleButton.Dispose(); VisibleButton = null; } if (EditButton != null) { EditButton.Dispose(); EditButton = null; } }