void OnEnable() {
			Instance = this;
			this.titleContent = new GUIContent( R2DD_Lang.windowTitle, R2DD_Resources.Instance.windowIcon );

			R2DC_Main.Instance.EnabledR2D();

			SceneView.onSceneGUIDelegate += OnSceneGUI;
			EditorApplication.hierarchyWindowChanged += OnHierarchyChanged;
			AppDomain.CurrentDomain.DomainUnload += OnDomainUnload;
		}
Beispiel #2
0
        void OnEnable()
        {
            Instance          = this;
            this.titleContent = new GUIContent(R2DD_Lang.windowTitle, R2DD_Resources.Instance.windowIcon);

            R2DC_Main.Instance.EnabledR2D();

            SceneView.onSceneGUIDelegate             += OnSceneGUI;
            EditorApplication.hierarchyWindowChanged += OnHierarchyChanged;
            AppDomain.CurrentDomain.DomainUnload     += OnDomainUnload;
        }
Beispiel #3
0
 static void OpenWindow()
 {
     if (Instance == null)
     {
         R2DE_EditorWindow r2dWindow = ( R2DE_EditorWindow )EditorWindow.GetWindow(typeof(R2DE_EditorWindow));
         r2dWindow.minSize = new Vector2(windowWidth, windowHeight);
         r2dWindow.maxSize = r2dWindow.minSize;
     }
     else
     {
         Instance.Close();
     }
 }
        public void HandleInteraction()
        {
            if (!state.displayGuides)
            {
                return;
            }

            EventType eventType = Event.current.type;

            if (Event.current.button != 0)
            {
                eventType = EventType.Ignore;
            }

            Vector2 mousePosition = Event.current.mousePosition;

            mousePosition.y = viewPixelFrame.height - mousePosition.y + 5f;

            int hGuideIndex = -1;
            int vGuideIndex = -1;

            if (hoverGuide != Vector2.zero)
            {
                utils.RepaintSceneView();
            }

            hoverGuide = Vector2.zero;

            if (creatingHGuide)
            {
                ShowHorizontalCursor();
            }
            else if (creatingVGuide)
            {
                ShowVerticalCursor();
            }
            else
            {
                if (IsInRenderBounds(mousePosition) && state.displayGuides && !state.lockGuides)
                {
                    hGuideIndex = GetHGuideHitBoxIndex(mousePosition);

                    if (hGuideIndex == -1)
                    {
                        vGuideIndex = GetVGuideHitBoxIndex(mousePosition);

                        if (vGuideIndex != -1)
                        {
                            ShowVerticalCursor();
                            hoverGuide.x = float.Parse(state.vGuides[vGuideIndex]);
                            utils.RepaintSceneView();
                        }
                    }
                    else
                    {
                        ShowHorizontalCursor();
                        hoverGuide.y = float.Parse(state.hGuides[hGuideIndex]);
                        utils.RepaintSceneView();
                    }
                }
            }

            switch (eventType)
            {
            case EventType.MouseDown:

                if (!IsCreatingGuides())
                {
                    if (IsOnTopRuler(mousePosition))
                    {
                        HotControl();
                        creatingHGuide = true;
                        utils.RepaintSceneView();
                    }
                    else if (IsOnLeftRuler(mousePosition))
                    {
                        HotControl();
                        creatingVGuide = true;
                        utils.RepaintSceneView();
                    }
                    else
                    {
                        if (hGuideIndex > -1)
                        {
                            HotControl();
                            state.hGuides.RemoveAt(hGuideIndex);
                            creatingHGuide = true;
                            UpdateLiveGuidePosition(mousePosition);
                            utils.RepaintSceneView();
                        }
                        else if (vGuideIndex > -1)
                        {
                            HotControl();
                            state.vGuides.RemoveAt(vGuideIndex);
                            creatingVGuide = true;
                            UpdateLiveGuidePosition(mousePosition);
                            utils.RepaintSceneView();
                        }
                    }
                }

                break;

            case EventType.MouseUp:

                if (IsCreatingGuides())
                {
                    if (IsInRenderBounds(mousePosition))
                    {
                        CompleteGuideCreation();
                    }
                    else
                    {
                        CancelGuideCreation();
                    }

                    if (IsOnLockButton(mousePosition))
                    {
                        R2DE_EditorWindow.ToggleGuidesLock();
                    }

                    GUIUtility.hotControl = 0;
                    utils.RepaintSceneView();
                }

                break;

            case EventType.MouseDrag:

                if (IsCreatingGuides())
                {
                    if (IsInRenderBounds(mousePosition))
                    {
                        UpdateLiveGuidePosition(mousePosition);
                    }
                    else if (IsOnCorner(mousePosition) ||
                             (IsOnTopRuler(mousePosition) && creatingHGuide) ||
                             (IsOnLeftRuler(mousePosition) && creatingVGuide))
                    {
                        // just hide the live guide
                        liveGuide = Vector2.zero;
                    }

                    utils.RepaintSceneView();
                }

                break;

            default:

                if (IsCreatingGuides() && IsOutOfBounds(mousePosition))
                {
                    GUIUtility.hotControl = 0;
                    CancelGuideCreation();
                    utils.RepaintSceneView();
                }

                break;
            }
        }