Example #1
0
        private void SetupCamera()
        {
            if (this.m_RenderMode == DrawCameraMode.Overdraw)
            {
                this.m_Camera.backgroundColor = Color.black;
            }
            else
            {
                this.m_Camera.backgroundColor = (Color) kSceneViewBackground;
            }
            EditorUtility.SetCameraAnimateMaterials(this.m_Camera, this.m_SceneViewState.showMaterialUpdate);
            this.ResetIfNaN();
            this.m_Camera.transform.rotation = this.m_Rotation.value;
            float aspectNeutralFOV = this.m_Ortho.Fade(90f, 0f);
            if (aspectNeutralFOV > 3f)
            {
                this.m_Camera.orthographic = false;
                this.m_Camera.fieldOfView = this.GetVerticalFOV(aspectNeutralFOV);
            }
            else
            {
                this.m_Camera.orthographic = true;
                this.m_Camera.orthographicSize = this.GetVerticalOrthoSize();
            }
            this.m_Camera.transform.position = this.m_Position.value + (this.m_Camera.transform.rotation * new Vector3(0f, 0f, -this.cameraDistance));
            float num2 = Mathf.Max((float) 1000f, (float) (2000f * this.size));
            this.m_Camera.nearClipPlane = num2 * 5E-06f;
            this.m_Camera.farClipPlane = num2;
            this.m_Camera.renderingPath = GetSceneViewRenderingPath();
            if (!this.CheckDrawModeForRenderingPath(this.m_RenderMode))
            {
                this.m_RenderMode = DrawCameraMode.Textured;
            }
            this.SetSceneCameraHDRAndDepthModes();
            Handles.EnableCameraFlares(this.m_Camera, this.m_SceneViewState.showFlares);
            Handles.EnableCameraSkybox(this.m_Camera, this.m_SceneViewState.showSkybox);
            this.m_Light[0].transform.position = this.m_Camera.transform.position;
            this.m_Light[0].transform.rotation = this.m_Camera.transform.rotation;
            if (this.m_AudioPlay)
            {
                AudioUtil.SetListenerTransform(this.m_Camera.transform);
                AudioUtil.UpdateAudio();
            }
            if (this.m_ViewIsLockedToObject && (Selection.gameObjects.Length > 0))
            {
                switch (this.m_DraggingLockedState)
                {
                    case DraggingLockedState.NotDragging:
                        this.m_Position.value = Selection.activeGameObject.transform.position;
                        break;

                    case DraggingLockedState.LookAt:
                        if (!this.m_Position.value.Equals(Selection.activeGameObject.transform.position))
                        {
                            if (!EditorApplication.isPlaying)
                            {
                                this.m_Position.target = Selection.activeGameObject.transform.position;
                            }
                            else
                            {
                                this.m_Position.value = Selection.activeGameObject.transform.position;
                            }
                        }
                        else
                        {
                            this.m_DraggingLockedState = DraggingLockedState.NotDragging;
                        }
                        break;
                }
            }
        }
Example #2
0
 public override void OnEnable()
 {
     base.titleContent = base.GetLocalizedTitleContent();
     this.m_RectSelection = new RectSelection(this);
     if (this.grid == null)
     {
         this.grid = new SceneViewGrid();
     }
     this.grid.Register(this);
     if (this.svRot == null)
     {
         this.svRot = new SceneViewRotation();
     }
     this.svRot.Register(this);
     base.autoRepaintOnSceneChange = true;
     this.m_Rotation.valueChanged.AddListener(new UnityAction(this.Repaint));
     this.m_Position.valueChanged.AddListener(new UnityAction(this.Repaint));
     this.m_Size.valueChanged.AddListener(new UnityAction(this.Repaint));
     this.m_Ortho.valueChanged.AddListener(new UnityAction(this.Repaint));
     base.wantsMouseMove = true;
     base.dontClearBackground = true;
     s_SceneViews.Add(this);
     this.m_Lighting = EditorGUIUtility.IconContent("SceneviewLighting", "Lighting|The scene lighting is used when toggled on. When toggled off a light attached to the scene view camera is used.");
     this.m_Fx = EditorGUIUtility.IconContent("SceneviewFx", "Fx|Toggles skybox, fog and lens flare effects.");
     this.m_AudioPlayContent = EditorGUIUtility.IconContent("SceneviewAudio", "AudioPlay|Toggles audio on or off.");
     this.m_GizmosContent = new GUIContent("Gizmos");
     this.m_2DModeContent = new GUIContent("2D");
     this.m_SceneViewOverlay = new SceneViewOverlay(this);
     EditorApplication.modifierKeysChanged = (EditorApplication.CallbackFunction) Delegate.Combine(EditorApplication.modifierKeysChanged, new EditorApplication.CallbackFunction(SceneView.RepaintAll));
     this.m_DraggingLockedState = DraggingLockedState.NotDragging;
     this.CreateSceneCameraAndLights();
     if (this.m_2DMode)
     {
         this.LookAt(this.pivot, Quaternion.identity, this.size, true, true);
     }
     base.OnEnable();
 }