示例#1
0
        protected override void AwakeOverride()
        {
            base.AwakeOverride();

            if (SceneCamera == null)
            {
                SceneCamera = Camera.main;
            }

            if (HandlesParent == null)
            {
                HandlesParent = transform;
            }

            GameObject positionHandle = new GameObject();

            positionHandle.name          = "PositionHandle";
            m_positionHandle             = positionHandle.AddComponent <PositionHandle>();
            m_positionHandle.Model       = m_positonHandleModel;
            m_positionHandle.SceneCamera = SceneCamera;
            positionHandle.SetActive(false);
            positionHandle.transform.SetParent(HandlesParent);

            GameObject rotationHandle = new GameObject();

            rotationHandle.name          = "RotationHandle";
            m_rotationHandle             = rotationHandle.AddComponent <RotationHandle>();
            m_rotationHandle.Model       = m_rotationHandleModel;
            m_rotationHandle.SceneCamera = SceneCamera;
            rotationHandle.SetActive(false);
            rotationHandle.transform.SetParent(HandlesParent);

            GameObject scaleHandle = new GameObject();

            scaleHandle.name          = "ScaleHandle";
            m_scaleHandle             = scaleHandle.AddComponent <ScaleHandle>();
            m_scaleHandle.Model       = m_scaleHandleModel;
            m_scaleHandle.SceneCamera = SceneCamera;
            scaleHandle.SetActive(false);
            scaleHandle.transform.SetParent(HandlesParent);

            BoxSelection.Filtering            += OnBoxSelectionFiltering;
            RuntimeSelection.SelectionChanged += OnRuntimeSelectionChanged;
            RuntimeTools.ToolChanged          += OnRuntimeToolChanged;

            if (InputController.Instance == null)
            {
                gameObject.AddComponent <InputController>();
            }
        }
        protected override void AwakeOverride()
        {
            base.AwakeOverride();

            Window.IOCContainer.RegisterFallback <IScenePivot>(this);
            Window.IOCContainer.RegisterFallback <IRuntimeSelectionComponent>(this);

            if (m_boxSelection == null)
            {
                m_boxSelection = GetComponentInChildren <BoxSelection>(true);
            }
            if (m_positionHandle == null)
            {
                m_positionHandle = GetComponentInChildren <PositionHandle>(true);
            }
            if (m_rotationHandle == null)
            {
                m_rotationHandle = GetComponentInChildren <RotationHandle>(true);
            }
            if (m_scaleHandle == null)
            {
                m_scaleHandle = GetComponentInChildren <ScaleHandle>(true);
            }

            if (m_boxSelection != null)
            {
                if (m_boxSelection.Window == null)
                {
                    m_boxSelection.Window = Window;
                }

                m_boxSelection.Filtering += OnBoxSelectionFiltering;
            }

            if (m_positionHandle != null)
            {
                if (m_positionHandle.Window == null)
                {
                    m_positionHandle.Window = Window;
                }

                m_positionHandle.gameObject.SetActive(true);
                m_positionHandle.gameObject.SetActive(false);
            }

            if (m_rotationHandle != null)
            {
                if (m_rotationHandle.Window == null)
                {
                    m_rotationHandle.Window = Window;
                }

                m_rotationHandle.gameObject.SetActive(true);
                m_rotationHandle.gameObject.SetActive(false);
            }

            if (m_scaleHandle != null)
            {
                if (m_scaleHandle.Window == null)
                {
                    m_scaleHandle.Window = Window;
                }
                m_scaleHandle.gameObject.SetActive(true);
                m_scaleHandle.gameObject.SetActive(false);
            }

            if (m_grid != null)
            {
                if (m_grid.Window == null)
                {
                    m_grid.Window = Window;
                }
            }

            Editor.Selection.SelectionChanged += OnRuntimeSelectionChanged;
            Editor.Tools.ToolChanged          += OnRuntimeToolChanged;

            if (m_pivot == null)
            {
                GameObject pivot = new GameObject("Pivot");
                pivot.transform.SetParent(transform, true);
                pivot.transform.position = Vector3.zero;
                m_pivot = pivot.transform;
            }

            if (m_secondaryPivot == null)
            {
                GameObject secondaryPivot = new GameObject("SecondaryPivot");
                secondaryPivot.transform.SetParent(transform, true);
                secondaryPivot.transform.position = Vector3.zero;
                m_secondaryPivot = secondaryPivot.transform;
            }

            Window.Camera.transform.LookAt(m_pivot);

            OnRuntimeSelectionChanged(null);
        }
示例#3
0
        protected override void AwakeOverride()
        {
            base.AwakeOverride();

            Window.IOCContainer.RegisterFallback <IScenePivot>(this);
            Window.IOCContainer.RegisterFallback <IRuntimeSelectionComponent>(this);

            if (m_outlineManager == null)
            {
                m_outlineManager = GetComponentInChildren <OutlineManager>(true);
                if (m_outlineManager != null)
                {
                    m_outlineManager.Camera = Window.Camera;
                }
            }

            if (m_boxSelection == null)
            {
                m_boxSelection = GetComponentInChildren <BoxSelection>(true);
            }
            if (m_positionHandle == null)
            {
                m_positionHandle = GetComponentInChildren <PositionHandle>(true);
            }
            if (m_rotationHandle == null)
            {
                m_rotationHandle = GetComponentInChildren <RotationHandle>(true);
            }
            if (m_scaleHandle == null)
            {
                m_scaleHandle = GetComponentInChildren <ScaleHandle>(true);
            }
            if (m_rectTool == null)
            {
                m_rectTool = GetComponentInChildren <RectTool>(true);
            }
            if (m_grid == null)
            {
                m_grid = GetComponentInChildren <SceneGrid>(true);
            }

            if (m_boxSelection != null)
            {
                if (m_boxSelection.Window == null)
                {
                    m_boxSelection.Window = Window;
                }

                m_boxSelection.Filtering += OnBoxSelectionFiltering;
                m_boxSelection.Selection += OnBoxSelection;
            }

            if (m_positionHandle != null)
            {
                if (m_positionHandle.Window == null)
                {
                    m_positionHandle.Window = Window;
                }

                m_positionHandle.gameObject.SetActive(true);
                m_positionHandle.gameObject.SetActive(false);

                m_positionHandle.BeforeDrag.AddListener(OnBeforeDrag);
                m_positionHandle.Drop.AddListener(OnDrop);
            }

            if (m_rotationHandle != null)
            {
                if (m_rotationHandle.Window == null)
                {
                    m_rotationHandle.Window = Window;
                }

                m_rotationHandle.gameObject.SetActive(true);
                m_rotationHandle.gameObject.SetActive(false);

                m_rotationHandle.BeforeDrag.AddListener(OnBeforeDrag);
                m_rotationHandle.Drop.AddListener(OnDrop);
            }

            if (m_scaleHandle != null)
            {
                if (m_scaleHandle.Window == null)
                {
                    m_scaleHandle.Window = Window;
                }
                m_scaleHandle.gameObject.SetActive(true);
                m_scaleHandle.gameObject.SetActive(false);

                m_scaleHandle.BeforeDrag.AddListener(OnBeforeDrag);
                m_scaleHandle.Drop.AddListener(OnDrop);
            }


            if (m_rectTool != null)
            {
                if (m_rectTool.Window == null)
                {
                    m_rectTool.Window = Window;
                }
                m_rectTool.gameObject.SetActive(true);
                m_rectTool.gameObject.SetActive(false);

                m_rectTool.BeforeDrag.AddListener(OnBeforeDrag);
                m_rectTool.Drop.AddListener(OnDrop);
            }

            if (m_grid != null)
            {
                if (m_grid.Window == null)
                {
                    m_grid.Window = Window;
                }
            }

            Editor.Selection.SelectionChanged += OnRuntimeSelectionChanged;
            Editor.Tools.ToolChanged          += OnRuntimeToolChanged;

            if (m_pivot == null)
            {
                GameObject pivot = new GameObject("Pivot");
                pivot.transform.SetParent(transform, true);
                pivot.transform.position = Vector3.zero;
                m_pivot = pivot.transform;
            }

            if (m_secondaryPivot == null)
            {
                GameObject secondaryPivot = new GameObject("SecondaryPivot");
                secondaryPivot.transform.SetParent(transform, true);
                secondaryPivot.transform.position = Vector3.zero;
                m_secondaryPivot = secondaryPivot.transform;
            }

            ApplySizeOfGrid();
            ApplyIsGridEnabled();

            OnRuntimeSelectionChanged(null);
        }
示例#4
0
        protected override void AwakeOverride()
        {
            base.AwakeOverride();

            if (m_boxSelection == null)
            {
                m_boxSelection = GetComponentInChildren <BoxSelection>(true);
            }
            if (m_positionHandle == null)
            {
                m_positionHandle = GetComponentInChildren <PositionHandle>(true);
            }
            if (m_rotationHandle == null)
            {
                m_rotationHandle = GetComponentInChildren <RotationHandle>(true);
            }
            if (m_scaleHandle == null)
            {
                m_scaleHandle = GetComponentInChildren <ScaleHandle>(true);
            }

            if (m_boxSelection != null)
            {
                if (m_boxSelection.Window == null)
                {
                    m_boxSelection.Window = Window;
                }

                m_boxSelection.Filtering += OnBoxSelectionFiltering;
            }

            if (m_positionHandle != null)
            {
                if (m_positionHandle.Window == null)
                {
                    m_positionHandle.Window = Window;
                }

                m_positionHandle.gameObject.SetActive(true);
                m_positionHandle.gameObject.SetActive(false);
            }

            if (m_rotationHandle != null)
            {
                if (m_rotationHandle.Window == null)
                {
                    m_rotationHandle.Window = Window;
                }

                m_rotationHandle.gameObject.SetActive(true);
                m_rotationHandle.gameObject.SetActive(false);
            }

            if (m_scaleHandle != null)
            {
                if (m_scaleHandle.Window == null)
                {
                    m_scaleHandle.Window = Window;
                }
                m_scaleHandle.gameObject.SetActive(true);
                m_scaleHandle.gameObject.SetActive(false);
            }

            Editor.Selection.SelectionChanged += OnRuntimeSelectionChanged;
            Editor.Tools.ToolChanged          += OnRuntimeToolChanged;

            if (GetComponent <RuntimeSelectionInputBase>() == null)
            {
                gameObject.AddComponent <RuntimeSelectionInput>();
            }

            RuntimeSelectionComponentUI ui = Window.GetComponentInChildren <RuntimeSelectionComponentUI>(true);

            if (ui == null && !Editor.IsVR)
            {
                GameObject runtimeSelectionComponentUI = new GameObject("SelectionComponentUI");
                runtimeSelectionComponentUI.transform.SetParent(Window.transform, false);

                ui = runtimeSelectionComponentUI.AddComponent <RuntimeSelectionComponentUI>();
                RectTransform rt = runtimeSelectionComponentUI.GetComponent <RectTransform>();
                rt.SetSiblingIndex(0);
                rt.anchorMin = new Vector2(0, 0);
                rt.anchorMax = new Vector2(1, 1);
                rt.pivot     = new Vector2(0.5f, 0.5f);
                rt.offsetMax = new Vector2(0, 0);
                rt.offsetMin = new Vector2(0, 0);
            }

            if (ui != null)
            {
                ui.Selected   += OnUISelected;
                ui.Unselected += OnUIUnselected;
            }
        }