void DoDrawGizmos() { Rect rBound = new Rect(m_mapBouds.min, m_mapBouds.size); HandlesEx.DrawRectWithOutline(transform, rBound, new Color(0, 0, 0, 0), new Color(1, 1, 1, 0.5f)); if (ShowGrid) { if (IsInitialized()) { RecalculateMapBounds(); RebuildMapCells(); } { // draw tile cells Gizmos.color = new Color(1f, 1f, 1f, .2f); // Horizontal lines for (float i = 1; i < Width; i++) { Gizmos.DrawLine( this.transform.TransformPoint(new Vector3(m_mapBouds.min.x + i * CellSize.x, m_mapBouds.min.y)), this.transform.TransformPoint(new Vector3(m_mapBouds.min.x + i * CellSize.x, m_mapBouds.max.y)) ); } // Vertical lines for (float i = 1; i < Height; i++) { Gizmos.DrawLine( this.transform.TransformPoint(new Vector3(m_mapBouds.min.x, m_mapBouds.min.y + i * CellSize.y, 0)), this.transform.TransformPoint(new Vector3(m_mapBouds.max.x, m_mapBouds.min.y + i * CellSize.y, 0)) ); } } } RebuildDrawMap(); }
public void OnSceneGUI() { PixelPerfectCameraCtrl owner = (PixelPerfectCameraCtrl)target; if (owner.KeepInsideBoundingBox) { HandlesEx.DrawRectWithOutline(owner.BoundingBox, new Color(0, 0, 0, 0), Color.cyan); // Draw Center Moving Handler EditorGUI.BeginChangeCheck(); Handles.color = Color.yellow; Vector3 vCenter = Handles.FreeMoveHandle(owner.BoundingBox.center, Quaternion.identity, 0.05f * HandleUtility.GetHandleSize(owner.transform.position), Vector3.zero, Handles.DotCap); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Move Center"); owner.BoundingBox.center = vCenter; EditorUtility.SetDirty(target); } // Draw Body Moving Handlers _DoBodyFreeMoveHandle(new Vector3(owner.BoundingBox.size.x / 2, 0f)); _DoBodyFreeMoveHandle(new Vector3(-owner.BoundingBox.size.x / 2, 0f)); _DoBodyFreeMoveHandle(new Vector3(0f, owner.BoundingBox.size.y / 2, 0f)); _DoBodyFreeMoveHandle(new Vector3(0f, -owner.BoundingBox.size.y / 2, 0f)); if (owner.BoundingBox.width < 0f) { owner.BoundingBox.position = new Vector2(owner.BoundingBox.position.x + owner.BoundingBox.width, owner.BoundingBox.y); owner.BoundingBox.width = -owner.BoundingBox.width; } if (owner.BoundingBox.height < 0f) { owner.BoundingBox.position = new Vector2(owner.BoundingBox.position.x, owner.BoundingBox.y + owner.BoundingBox.height); owner.BoundingBox.height = -owner.BoundingBox.height; } } }
/// <summary> /// Handles the scene GUI event. /// </summary> /// <param name="sceneView">Scene view.</param> private static void OnSceneGUI(SceneView sceneView) { if (clipBindingsSerialized.value == null) { return; } EditorClipBinding[] clipBindings = clipBindingsSerialized.value as EditorClipBinding[]; int bindingsLength = clipBindings.Length; Color clr = Color.red; Vector3[] positionsInKeyframe = null; AnimationClip clip = null; EditorClipBinding clipBindingCurrent = null; long indexListAndindexFramePacked = 0; Transform transformRoot = null; Transform transformFirstChild = null; bool gameObjectCharacterSelected = false; if (Selection.activeGameObject != null) { if (Tools.current == Tool.Move) { if (Selection.activeGameObject == __spaceGameObject) { gameObjectCharacterSelected = true; } else { clipBindingCurrent = clipBindings.FirstOrDefault((itm) => itm.gameObject == Selection.activeGameObject); // && clipBindingCurrent.gameObject.transform.position!=Tools.handlePosition if (clipBindingCurrent != null) { //clipBindingCurrent.gameObject.position has changed so recalcualte position offset clipBindingCurrent.positionOffset = Quaternion.Inverse(__spaceGameObject.transform.rotation) * (clipBindingCurrent.gameObject.transform.position - __spaceGameObject.transform.position); } } } else if (Tools.current == Tool.Rotate) { if (Selection.activeGameObject == __spaceGameObject) { gameObjectCharacterSelected = true; } else { clipBindingCurrent = clipBindings.FirstOrDefault((itm) => itm.gameObject == Selection.activeGameObject); // && clipBindingCurrent.gameObject.transform.position!=Tools.handleRotation if (clipBindingCurrent != null) { //clipBindingCurrent.gameObject.rotation has changed so recalcualte rotation offset clipBindingCurrent.rotationOffset = Quaternion.Inverse(__spaceGameObject.transform.rotation) * clipBindingCurrent.gameObject.transform.rotation; } } } } for (int i = 0; i < bindingsLength; i++) { clipBindingCurrent = clipBindings [i]; if (clipBindingCurrent.visible) { clip = clipBindingCurrent.clip; if (clip != null && clipBindingCurrent.gameObject != null && clipBindingCurrent.gameObject.transform.childCount > 0 && (transformFirstChild = clipBindingCurrent.gameObject.transform.GetChild(0)) != null) { if (gameObjectCharacterSelected) //=> move and/or rotate clip binding's gameobjects { GameObject gameObjectBinded = clipBindingCurrent.gameObject; gameObjectBinded.transform.rotation = __spaceGameObject.transform.rotation * clipBindingCurrent.rotationOffset; gameObjectBinded.transform.position = __spaceGameObject.transform.position + __spaceGameObject.transform.rotation * clipBindingCurrent.positionOffset; } transformRoot = clipBindingCurrent.gameObject.transform; positionsInKeyframe = AnimationUtilityEx.GetPositions(clip, AnimationUtility.CalculateTransformPath(transformFirstChild, transformRoot), transformRoot); if (positionsInKeyframe != null) { for (int j = 0; j < positionsInKeyframe.Length; j++) { indexListAndindexFramePacked = i; //put index of clipBinding in list/array indexListAndindexFramePacked = indexListAndindexFramePacked << 32 | (uint)j; //pack together with keyframe index //actualy this is static handle HandlesEx.DragHandle(positionsInKeyframe [j], 0.1f, Handles.SphereCap, Color.red, "(" + j + ")" + " " + Decimal.Round(Convert.ToDecimal(AnimationUtilityEx.GetTimeAt(clip, j, AnimationUtilityEx.EditorCurveBinding_PosX)), 2).ToString(), indexListAndindexFramePacked, onDragHandleEvent, new GUIContent[] { new GUIContent("Delete") }, new long[] { j }, null); } //save color clr = Handles.color; clipBindingCurrent.color.a = 1; Handles.color = clipBindingCurrent.color; Handles.DrawPolyLine(positionsInKeyframe); //restore color Handles.color = clr; } } } } //Debug.Log ("hot"+GUIUtility.hotControl); SceneView.RepaintAll(); }