Exemplo n.º 1
0
 void DrawRigGizmo(Transform rig)
 {
     //Handles.DrawWireCube(Vector3.zero, Vector3.one);
     //Gizmos.DrawCube(rig.position, Vector3.one);
     //    Handles.DrawWireCube(rig.position, Vector3.one);
     // return;
     if (rig.childCount > 0)
     {
         for (int i = 0, count = rig.childCount; i < count; ++i)
         {
             Transform child = rig.GetChild(i);
             HandlesUtils.DrawPyramid(rig.position, child.position, 1f);
             DrawRigGizmo(child);
         }
     }
 }
Exemplo n.º 2
0
        private void HandleMoveTool()
        {
            Quaternion parentRot = Quaternion.identity;
            Vector3    handlePos = _primaryItem.GetEditorPosition();

            if (_transform.parent != null)
            {
                handlePos = _transform.parent.TransformPoint(handlePos);
                parentRot = _transform.parent.transform.rotation;
            }
            EditorGUI.BeginChangeCheck();
            handlePos = HandlesUtils.HandlePosition(handlePos, _primaryItem.EditorPositionType, parentRot);
            if (EditorGUI.EndChangeCheck())
            {
                FinishMove(handlePos);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Takes care of the rendering-related stuff.
        /// </summary>
        ///
        /// <remarks>
        /// This is called by the drag point inspector.
        /// </remarks>
        ///
        /// <param name="evt">Event from the inspector</param>
        /// <param name="onChange"></param>
        public void OnSceneGUI(Event evt, OnDragPointPositionChange onChange = null)
        {
            switch (evt.type)
            {
            case EventType.Layout:
                InitSceneGui();
                break;

            case EventType.MouseDown:
                OnMouseDown();
                break;

            case EventType.Repaint:
                CurveTravellerVisible = false;
                break;
            }

            // Handle the common position handler for all selected control points
            if (SelectedControlPoints.Count > 0)
            {
                var parentRot = Quaternion.identity;
                if (Transform.parent != null)
                {
                    parentRot = Transform.parent.transform.rotation;
                }
                EditorGUI.BeginChangeCheck();
                var newHandlePos = HandlesUtils.HandlePosition(_positionHandlePosition, DragPointEditable.GetHandleType(), parentRot);
                if (EditorGUI.EndChangeCheck())
                {
                    onChange?.Invoke(newHandlePos);
                    var deltaPosition = newHandlePos - _positionHandlePosition;
                    foreach (var controlPoint in SelectedControlPoints)
                    {
                        controlPoint.WorldPos += deltaPosition;
                        controlPoint.UpdateDragPoint(DragPointEditable, Transform);
                    }
                }
            }

            //Render the curve & drag points
            _sceneViewHandler.OnSceneGUI();
        }