예제 #1
0
        public static void CheckRefocus()
        {
#if UNITY_EDITOR
            if (refocusOnThis != null)
            {
                scipframes--;
                if (scipframes == 0)
                {
                    UnityHelperFunctions.FocusOn(refocusOnThis);
                    refocusOnThis = null;
                    scipframes    = 3;
                }
            }
#endif
        }
예제 #2
0
        public void CloseAllButThis(T trg)
        {
            trg.enabled = true;
            GameObject go = trg.gameObject;

            Component[] cs = go.GetComponents(typeof(Component));

            foreach (Component c in cs)
            {
                if (c.GetType() != typeof(T))
                {
                    UnityEditorInternal.InternalEditorUtility.SetIsInspectorExpanded(c, false);
                }
            }


            UnityHelperFunctions.FocusOn(null);
            PlaytimeToolComponent.refocusOnThis = go;
        }
예제 #3
0
        public virtual void GridUpdate(SceneView sceneview)
        {
            if (!IsCurrentTool())
            {
                return;
            }


            Event e = Event.current;

            if (e.isMouse)
            {
                if (e.button != 0)
                {
                    return;
                }

                L_mouseDwn = (e.type == EventType.MouseDown) && (e.button == 0);
                L_mouseUp  = (e.type == EventType.MouseUp) && (e.button == 0);

                mousePosition = Event.current.mousePosition;

                if (Camera.current != null && (mousePosition.x < 0 || mousePosition.y < 0 ||
                                               mousePosition.x > Camera.current.pixelWidth ||
                                               mousePosition.y > Camera.current.pixelHeight))
                {
                    return;
                }

                rayGUI = HandleUtility.GUIPointToWorldRay(mousePosition);
                EditorInputManager.raySceneView = rayGUI;
            }

            FeedEvents(e);

            if (e.isMouse || (e.type == EventType.ScrollWheel))
            {
                EditorInputManager.feedMouseEvent(e);
            }

            if (e.isMouse)
            {
                RaycastHit hit;
                bool       ishit = Physics.Raycast(rayGUI, out hit);

                T pp = ishit ? hit.transform.GetComponent <T>() : null;

                bool refocus = OnEditorRayHit(hit, rayGUI);

                if ((L_mouseDwn) && (e.button == 0) && (refocus) && ishit)
                {
                    if ((pp != null) && (pp == painter) && (AllowEditing(painter)))
                    {
                        HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
                    }

                    UnityHelperFunctions.FocusOn(hit.transform.gameObject);
                }

                if ((!navigating) && AllowEditing(painter))
                {
                    e.Use();
                }
            }
        }