private void Start()
        {
            BaseGizmoInput input = GetComponent <BaseGizmoInput>();

            if (input == null || input.Gizmo != this)
            {
                input       = gameObject.AddComponent <BaseGizmoInput>();
                input.Gizmo = this;
            }

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

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

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

            if (EnableUndo)
            {
                if (!RuntimeUndoInput.IsInitialized)
                {
                    GameObject runtimeUndo = new GameObject();
                    runtimeUndo.name = "RuntimeUndo";
                    runtimeUndo.AddComponent <RuntimeUndoInput>();
                }
            }

            if (GLRenderer.Instance == null)
            {
                GameObject glRenderer = new GameObject();
                glRenderer.name = "GLRenderer";
                glRenderer.AddComponent <GLRenderer>();
            }

            if (SceneCamera != null)
            {
                if (!SceneCamera.GetComponent <GLCamera>())
                {
                    SceneCamera.gameObject.AddComponent <GLCamera>();
                }
            }

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

            StartOverride();
        }
        protected override void OnDestroyOverride()
        {
            base.OnDestroyOverride();
            BaseGizmoInput gizmoInput = GetComponent <BaseGizmoInput>();

            if (gizmoInput)
            {
                Destroy(gizmoInput);
            }

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

            if (Window.Editor.Tools.ActiveTool == this)
            {
                Window.Editor.Tools.ActiveTool = null;
            }
        }
Beispiel #3
0
        protected override void OnDestroyOverride()
        {
            base.OnDestroyOverride();
            BaseGizmoInput gizmoInput = GetComponent <BaseGizmoInput>();

            if (gizmoInput)
            {
                Destroy(gizmoInput);
            }

            if (Window.Editor.Tools.ActiveTool == this)
            {
                Window.Editor.Tools.ActiveTool = null;
            }

            if (m_rteCamera != null)
            {
                m_rteCamera.CommandBufferRefresh -= OnCommandBufferRefresh;
                m_rteCamera.RefreshCommandBuffer();
            }
        }
        protected override void Start()
        {
            base.Start();

            BaseGizmoInput input = GetComponent <BaseGizmoInput>();

            if (input == null || input.Gizmo != this)
            {
                input       = gameObject.AddComponent <BaseGizmoInput>();
                input.Gizmo = this;
            }

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

            if (EnableUndo)
            {
                if (!RuntimeUndoInput.IsInitialized)
                {
                    GameObject runtimeUndo = new GameObject();
                    runtimeUndo.name = "RuntimeUndo";
                    runtimeUndo.AddComponent <RuntimeUndoInput>();
                }
            }

            IRTEGraphicsLayer graphicsLayer = Window.IOCContainer.Resolve <IRTEGraphicsLayer>();

            if (graphicsLayer != null && !ForceCreateCamera)
            {
                m_rteCamera = graphicsLayer.Camera;
            }

            if (m_rteCamera == null && SceneCamera != null)
            {
                IRTEGraphics graphics = IOC.Resolve <IRTEGraphics>();
                if (graphics != null)
                {
                    m_rteCamera = graphics.GetOrCreateCamera(SceneCamera, CameraEvent);
                }

                if (m_rteCamera == null)
                {
                    m_rteCamera       = SceneCamera.gameObject.AddComponent <RTECamera>();
                    m_rteCamera.Event = CameraEvent;
                }
            }

            if (m_rteCamera != null)
            {
                m_prevPosition = transform.position;
                m_prevRotation = transform.rotation;
                m_prevScale    = transform.localScale;

                m_prevCamPosition  = m_rteCamera.Camera.transform.position;
                m_prevCamRotation  = m_rteCamera.Camera.transform.rotation;
                m_prevOrthographic = m_rteCamera.Camera.orthographic;

                m_rteCamera.CommandBufferRefresh += OnCommandBufferRefresh;
                m_rteCamera.RefreshCommandBuffer();
            }
#pragma warning disable CS0612
            StartOverride();
#pragma warning restore CS0612
        }
Beispiel #5
0
        private void Start()
        {
            BaseGizmoInput input = GetComponent <BaseGizmoInput>();

            if (input == null || input.Gizmo != this)
            {
                input       = gameObject.AddComponent <BaseGizmoInput>();
                input.Gizmo = this;
            }

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

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

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

            if (EnableUndo)
            {
                if (!RuntimeUndoInput.IsInitialized)
                {
                    GameObject runtimeUndo = new GameObject();
                    runtimeUndo.name = "RuntimeUndo";
                    runtimeUndo.AddComponent <RuntimeUndoInput>();
                }
            }

            IRTEGraphicsLayer graphicsLayer = Window.IOCContainer.Resolve <IRTEGraphicsLayer>();

            if (graphicsLayer != null)
            {
                m_rteCamera = graphicsLayer.Camera;
            }

            if (m_rteCamera == null && SceneCamera != null)
            {
                m_rteCamera = SceneCamera.GetComponent <IRTECamera>();
                if (m_rteCamera == null)
                {
                    m_rteCamera       = SceneCamera.gameObject.AddComponent <RTECamera>();
                    m_rteCamera.Event = UnityEngine.Rendering.CameraEvent.AfterImageEffectsOpaque;
                }
            }

            if (m_rteCamera != null)
            {
                m_prevPosition = transform.position;
                m_prevRotation = transform.rotation;
                m_prevScale    = transform.localScale;

                m_prevCamPosition  = m_rteCamera.Camera.transform.position;
                m_prevCamRotation  = m_rteCamera.Camera.transform.rotation;
                m_prevOrthographic = m_rteCamera.Camera.orthographic;

                m_rteCamera.CommandBufferRefresh += OnCommandBufferRefresh;
                m_rteCamera.RefreshCommandBuffer();
            }

            StartOverride();
        }