Example #1
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();
        }