Example #1
0
        private void MoveToolGUI(Vector3 handlePosition, bool isStatic)
        {
            RuntimeTransformManipulator.BeginManipulationHandling(false);
            RuntimeEditorGUI.BeginChangeCheck();
            Vector3 a = RuntimeHandles.DoPositionHandle(handlePosition, Tools.handleRotation);

            if (RuntimeEditorGUI.EndChangeCheck() && !isStatic)
            {
                Vector3 positionDelta = a - RuntimeTransformManipulator.mouseDownHandlePosition;
                RuntimeTransformManipulator.SetMinDragDifferenceForPos(handlePosition);
                RuntimeTransformManipulator.SetPositionDelta(positionDelta);
            }
            RuntimeTransformManipulator.EndManipulationHandling();
        }
Example #2
0
        private void OnGUI()
        {
            if (camera == null)
            {
                camera = Player.Camera;
                return;
            }

            var current = Event.current;

            RuntimeHandles.SetCamera(camera.pixelRect, camera);
            RuntimeHandlesUtility.BeginHandles();
            RuntimeHandles.currentCamera = camera;
            WorldProp selection = RuntimeSelection.activeProp;

            if (selection != null)
            {
                switch (Tools.current)
                {
                case RuntimeTool.Move:
                    MoveToolGUI(MoveToolGUI);
                    break;

                case RuntimeTool.Rotate:
                    RuntimeEditorGUI.BeginChangeCheck();
                    Quaternion rotation = RuntimeHandles.DoRotationHandle(selection.Rotation, Tools.handlePosition);
                    if (RuntimeEditorGUI.EndChangeCheck())
                    {
                        UndoManager.PushUndo("Rotate", r => selection.SetRotation((Quaternion)r, true), selection.Rotation);
                    }
                    selection.SetRotation(rotation, true);
                    break;

                case RuntimeTool.Scale:
                    Vector3 scale = RuntimeHandles.DoScaleHandle(selection.Scale, Tools.handlePosition, Tools.handleRotation);
                    selection.SetScale(scale, true);
                    break;
                }
            }
            RuntimeHandlesUtility.EndHandles();
        }