protected override void AwakeOverride()
        {
            base.AwakeOverride();

            m_allHandles.Add(this);

            RuntimeHandlesComponent.InitializeIfRequired(ref Appearance);
            RuntimeHandlesHitTester.InitializeIfRequired(Window, ref HitTester);

            if (m_targets != null && m_targets.Length > 0)
            {
                var lockObject = LockObject;
                if (m_commonCenter == null || m_commonCenter.Length == 0 || m_commonCenter[0] != m_targets[0])
                {
                    Targets = m_targets;
                }
                if (lockObject != null)
                {
                    LockObject = lockObject;
                }
            }

            if (Targets == null || Targets.Length == 0)
            {
                var lockObject = LockObject;
                Targets = new[] { transform };
                if (lockObject != null)
                {
                    LockObject = lockObject;
                }
            }

            if (Model != null)
            {
                bool activeSelf = Model.gameObject.activeSelf;
                Model.gameObject.SetActive(false);
                BaseHandleModel model = Instantiate(Model, transform.parent);

                model.name       = Model.name;
                model.Appearance = Appearance;
                model.Window     = Window;

                Model.gameObject.SetActive(activeSelf);

                if (enabled)
                {
                    model.gameObject.SetActive(true);
                    Model = model;
                    Model.SetLock(LockObject);
                }
                else
                {
                    Model = model;
                }

                Model.ModelScale      = Appearance.HandleScale;
                Model.SelectionMargin = Appearance.SelectionMargin;
            }
        }
Example #2
0
        protected override void AwakeOverride()
        {
            base.AwakeOverride();

            m_allHandles.Add(this);

            RuntimeHandlesComponent.InitializeIfRequired(ref Appearance);
            RuntimeHandlesHitTester.InitializeIfRequired(Window, ref HitTester);

            if (m_targets != null && m_targets.Length > 0)
            {
                var lockObject = LockObject;
                Targets = m_targets;
                if (lockObject != null)
                {
                    LockObject = lockObject;
                }
            }

            if (Targets == null || Targets.Length == 0)
            {
                var lockObject = LockObject;
                Targets = new[] { transform };
                if (lockObject != null)
                {
                    LockObject = lockObject;
                }
            }

            if (GLRenderer.Instance == null)
            {
                GameObject glRenderer = new GameObject();
                glRenderer.name = "GLRenderer";
                glRenderer.transform.SetParent(Editor.Root, false);
                glRenderer.AddComponent <GLRenderer>();
            }

            if (GLRenderer.Instance != null)
            {
                GLRenderer.Instance.Add(this);
            }

            if (Targets[0].position != transform.position)
            {
                transform.position = Targets[0].position;
            }

            if (Model != null)
            {
                bool activeSelf = Model.gameObject.activeSelf;
                Model.gameObject.SetActive(false);
                BaseHandleModel model = Instantiate(Model, transform.parent);

                model.name       = Model.name;
                model.Appearance = Appearance;
                model.Window     = Window;

                Model.gameObject.SetActive(activeSelf);

                if (enabled)
                {
                    model.gameObject.SetActive(true);
                    Model = model;
                    Model.SetLock(LockObject);
                }
                else
                {
                    Model = model;
                }

                Model.ModelScale      = Appearance.HandleScale;
                Model.SelectionMargin = Appearance.SelectionMargin;
            }
        }