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

            Window.IOCContainer.RegisterFallback <IRuntimeSceneComponent>(this);

            if (Run.Instance == null)
            {
                GameObject runGO = new GameObject("Run");
                runGO.transform.SetParent(transform, false);
                runGO.name = "Run";
                runGO.AddComponent <Run>();
            }

            if (ViewTexture == null)
            {
                ViewTexture = Resources.Load <Texture2D>("RTH_Eye");
            }
            if (MoveTexture == null)
            {
                MoveTexture = Resources.Load <Texture2D>("RTH_Hand");
            }
            if (FreeMoveTexture == null)
            {
                FreeMoveTexture = Resources.Load <Texture2D>("RTH_FreeMove");
            }

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

            if (m_sceneGizmo == null)
            {
                m_sceneGizmo = GetComponentInChildren <SceneGizmo>(true);
            }

            if (m_sceneGizmo != null)
            {
                if (m_sceneGizmo.Window == null)
                {
                    m_sceneGizmo.Window = Window;
                }
                m_sceneGizmo.OrientationChanging.AddListener(OnSceneGizmoOrientationChanging);
                m_sceneGizmo.OrientationChanged.AddListener(OnSceneGizmoOrientationChanged);
                m_sceneGizmo.ProjectionChanged.AddListener(OnSceneGizmoProjectionChanged);
                m_sceneGizmo.Pivot = PivotTransform;
                if (!IsSceneGizmoEnabled)
                {
                    m_sceneGizmo.gameObject.SetActive(false);
                }
            }

            Transform camTransform = Window.Camera.transform;

            camTransform.LookAt(Pivot);
            m_targetRotation = camTransform.rotation;
            m_targetPosition = camTransform.position;
            m_orbitDistance  = (Pivot - m_targetPosition).magnitude;
        }
Example #2
0
        protected override void AwakeOverride()
        {
            base.AwakeOverride();

            Window.IOCContainer.RegisterFallback <IRuntimeSceneComponent>(this);

            GameObject runGO = new GameObject("Run");

            runGO.transform.SetParent(transform, false);
            runGO.name = "Run";
            runGO.AddComponent <Run>();

            if (ViewTexture == null)
            {
                ViewTexture = Resources.Load <Texture2D>("RTH_Eye");
            }
            if (MoveTexture == null)
            {
                MoveTexture = Resources.Load <Texture2D>("RTH_Hand");
            }

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

            m_mouseOrbit = Window.Camera.GetComponent <MouseOrbit>();
            if (!m_mouseOrbit)
            {
                m_mouseOrbit = Window.Camera.gameObject.AddComponent <MouseOrbit>();
            }
            m_mouseOrbit.Target                     = PivotTransform;
            m_mouseOrbit.SecondaryTarget            = SecondaryPivotTransform;
            m_mouseOrbit.CanZoom                    = CanZoom;
            m_mouseOrbit.ChangeOrthographicSizeOnly = ChangeOrthographicSizeOnly;
            m_mouseOrbit.CanOrbit                   = CanOrbit;

            if (m_sceneGizmo == null)
            {
                m_sceneGizmo = GetComponentInChildren <SceneGizmo>(true);
            }

            if (m_sceneGizmo != null)
            {
                if (m_sceneGizmo.Window == null)
                {
                    m_sceneGizmo.Window = Window;
                }
                m_sceneGizmo.OrientationChanging.AddListener(OnSceneGizmoOrientationChanging);
                m_sceneGizmo.OrientationChanged.AddListener(OnSceneGizmoOrientationChanged);
                m_sceneGizmo.ProjectionChanged.AddListener(OnSceneGizmoProjectionChanged);
                m_sceneGizmo.Pivot = PivotTransform;
                if (!IsSceneGizmoEnabled)
                {
                    m_sceneGizmo.gameObject.SetActive(false);
                }
            }

            Window.Camera.transform.LookAt(Pivot);
        }
 private void Start()
 {
     if (m_sceneGizmo == null)
     {
         m_sceneGizmo = GetComponent <SceneGizmo>();
     }
     m_editor = m_sceneGizmo.Window.Editor;
 }
        protected override void AwakeOverride()
        {
            base.AwakeOverride();

            GameObject runGO = new GameObject("Run");

            runGO.transform.SetParent(transform, false);
            runGO.name = "Run";
            runGO.AddComponent <Run>();

            if (ViewTexture == null)
            {
                ViewTexture = Resources.Load <Texture2D>("RTH_Eye");
            }
            if (MoveTexture == null)
            {
                MoveTexture = Resources.Load <Texture2D>("RTH_Hand");
            }

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

            m_mouseOrbit = Window.Camera.GetComponent <MouseOrbit>();
            if (!m_mouseOrbit)
            {
                m_mouseOrbit = Window.Camera.gameObject.AddComponent <MouseOrbit>();
            }
            m_mouseOrbit.Target          = Pivot;
            m_mouseOrbit.SecondaryTarget = SecondaryPivot;

            if (m_sceneGizmo == null)
            {
                m_sceneGizmo = GetComponentInChildren <SceneGizmo>(true);
            }

            if (m_sceneGizmo != null)
            {
                if (m_sceneGizmo.Window == null)
                {
                    m_sceneGizmo.Window = Window;
                }
                m_sceneGizmo.OrientationChanging.AddListener(OnSceneGizmoOrientationChanging);
                m_sceneGizmo.OrientationChanged.AddListener(OnSceneGizmoOrientationChanged);
                m_sceneGizmo.ProjectionChanged.AddListener(OnSceneGizmoProjectionChanged);
                m_sceneGizmo.Pivot = Pivot;
            }
        }