Exemple #1
0
        private void ProcessSceneEvents()
        {
            if (sceneManipulator.Sync())
            {
                Repaint();
            }

            int controlId = GUIUtility.GetControlID(FocusType.Passive);

            if (Event.current.type == EventType.MouseDown && (Event.current.button == 0) && !Event.current.alt)
            {
                // If shift is held then always add, if control then always subtract, otherwise use intelligent pick mode
                PickMode mode = PickMode.Undecided;
                if (Event.current.shift)
                {
                    mode = PickMode.Additive;
                }
                else if (Event.current.control)
                {
                    mode = PickMode.Subtractive;
                }

                bool eventConsumed = sceneManipulator.DoMouseDown(mode);
                if (eventConsumed)
                {
                    activeMouseButton     = Event.current.button;
                    GUIUtility.hotControl = controlId;
                    Event.current.Use();
                }
            }
            else if (Event.current.type == EventType.MouseDrag && Event.current.button == activeMouseButton && !Event.current.alt)
            {
                bool eventConsumed = sceneManipulator.DoMouseDrag();
                if (eventConsumed)
                {
                    GUIUtility.hotControl = controlId;
                    Event.current.Use();
                    Repaint();
                }
            }
            else if (Event.current.type == EventType.MouseUp && Event.current.button == activeMouseButton && !Event.current.alt)
            {
                bool eventConsumed = sceneManipulator.DoMouseUp();
                if (eventConsumed)
                {
                    activeMouseButton     = -1;
                    GUIUtility.hotControl = 0;
                    Event.current.Use();
                }
            }
        }
Exemple #2
0
        public void OnSceneGUI()
        {
            //	Debug.Log ("Window.OnSceneGUI");

            if (sceneManipulator.Sync())
            {
                Repaint();
            }

            int controlId = GUIUtility.GetControlID(FocusType.Passive);

            if (Event.current.type == EventType.MouseDown && (Event.current.button == 0))
            {
                bool eventConsumed = sceneManipulator.DoMouseDown();
                if (eventConsumed)
                {
                    activeMouseButton     = Event.current.button;
                    GUIUtility.hotControl = controlId;
                    Event.current.Use();
                }
            }
            else if (Event.current.type == EventType.MouseDrag && Event.current.button == activeMouseButton)
            {
                bool eventConsumed = sceneManipulator.DoMouseDrag();
                if (eventConsumed)
                {
                    GUIUtility.hotControl = controlId;
                    Event.current.Use();
                    Repaint();
                }
            }
            else if (Event.current.type == EventType.MouseUp && Event.current.button == activeMouseButton)
            {
                bool eventConsumed = sceneManipulator.DoMouseUp();
                if (eventConsumed)
                {
                    activeMouseButton     = -1;
                    GUIUtility.hotControl = 0;
                    Event.current.Use();
                }
            }
        }