예제 #1
0
 public void ResynchronizeObjects()
 {
     Undo.RecordObject(this, "Resync objects");
     for (int i = 0; i < 2; i++)
     {
         SetCurrentPreviewObject(m_OriginalGameObject[m_CurrentEditionContextIndex], (LookDevEditionContext)i);
     }
     m_LookDevView.Frame(false);
 }
        public override void OnGUI(Rect rect)
        {
            if (m_LookDevView == null)
            {
                return;
            }

            GUILayout.BeginVertical();
            {
                // We need to have a sufficient size to display negative float number
                EditorGUIUtility.labelWidth = 130;
                EditorGUIUtility.fieldWidth = 35;

                // Look Dev view mode
                DrawHeader(styles.sMultiView);

                for (int i = 0; i < (int)LookDevMode.Count; ++i)
                {
                    EditorGUI.BeginChangeCheck();
                    bool value = GUILayout.Toggle(m_LookDevView.config.lookDevMode == (LookDevMode)i, styles.sMultiViewMode[i], styles.sMenuItem);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_LookDevView.UpdateLookDevModeToggle((LookDevMode)i, value);
                        m_LookDevView.Repaint();
                        GUIUtility.ExitGUI();
                    }
                }

                // Camera settings
                DrawSeparator();
                DrawHeader(styles.sCamera);

                if (GUILayout.Button(styles.sResetCamera, styles.sMenuItem))
                {
                    m_LookDevView.Frame();
                }

                m_LookDevView.config.enableToneMap = GUILayout.Toggle(m_LookDevView.config.enableToneMap, styles.sEnableToneMap, styles.sMenuItem);
                EditorGUI.BeginChangeCheck();
                // Cast to int to have integer step
                float newExposureRange = (float)EditorGUILayout.IntSlider(styles.sExposureRange, (int)m_LookDevView.config.exposureRange, 1, 32);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(m_LookDevView.config, "Change exposure range");
                    m_LookDevView.config.exposureRange = newExposureRange;
                }

                DrawSeparator();
                DrawHeader(styles.sLighting);

                EditorGUI.BeginChangeCheck();

                GUILayout.BeginHorizontal();
                m_LookDevView.config.enableShadowCubemap = GUILayout.Toggle(m_LookDevView.config.enableShadowCubemap, styles.sEnableShadows, styles.sMenuItem);
                GUILayout.EndHorizontal();
                if (EditorGUI.EndChangeCheck())
                {
                    m_LookDevView.Repaint();
                }

                EditorGUI.BeginChangeCheck();
                float newShadowDistance = EditorGUILayout.Slider(styles.sShadowDistance, m_LookDevView.config.shadowDistance, 0.0f, 1000.0f);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(m_LookDevView.config, "Change shadow distance");
                    m_LookDevView.config.shadowDistance = newShadowDistance;
                }

                DrawSeparator();
                DrawHeader(styles.sAnimation);

                GUILayout.BeginHorizontal();
                m_LookDevView.config.rotateObjectMode = GUILayout.Toggle(m_LookDevView.config.rotateObjectMode, styles.sRotateObjectMode, styles.sMenuItem);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                m_LookDevView.config.rotateEnvMode = GUILayout.Toggle(m_LookDevView.config.rotateEnvMode, styles.sRotateEnvMode, styles.sMenuItem);
                GUILayout.EndHorizontal();

                EditorGUI.BeginChangeCheck();
                float newObjRotationSpeed = EditorGUILayout.Slider(styles.sObjRotationSpeed, m_LookDevView.config.objRotationSpeed, -5.0f, 5.0f);

                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(m_LookDevView.config, "Change rotation speed");
                    m_LookDevView.config.objRotationSpeed = newObjRotationSpeed;
                }

                EditorGUI.BeginChangeCheck();
                float newEnvRotationSpeed = EditorGUILayout.Slider(styles.sEnvRotationSpeed, m_LookDevView.config.envRotationSpeed, -5.0f, 5.0f);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(m_LookDevView.config, "Change env speed");
                    m_LookDevView.config.envRotationSpeed = newEnvRotationSpeed;
                }

                DrawSeparator();
                DrawHeader(styles.sViewport);
                if (GUILayout.Button(styles.sResetView, styles.sMenuItem))
                {
                    m_LookDevView.ResetView();
                }

                DrawSeparator();
                DrawHeader(styles.sEnvLibrary);
                using (new EditorGUI.DisabledScope(!m_LookDevView.envLibrary.dirty))
                {
                    if (GUILayout.Button(styles.sSaveCurrentLibrary, styles.sMenuItem))
                    {
                        editorWindow.Close();
                        if (m_LookDevView.SaveLookDevLibrary())
                        {
                            m_LookDevView.envLibrary.dirty = false;
                        }
                        GUIUtility.ExitGUI();
                    }
                }
                if (GUILayout.Button(styles.sCreateNewLibrary, styles.sMenuItem))
                {
                    editorWindow.Close();
                    string assetPath = EditorUtility.SaveFilePanelInProject("Save New Environment Library", "New Env Library", "asset", "");
                    if (!string.IsNullOrEmpty(assetPath))
                    {
                        m_LookDevView.CreateNewLibrary(assetPath);
                    }

                    GUIUtility.ExitGUI();
                }
                EditorGUI.BeginChangeCheck();
                LookDevEnvironmentLibrary library = EditorGUILayout.ObjectField(m_LookDevView.userEnvLibrary, typeof(LookDevEnvironmentLibrary), false) as LookDevEnvironmentLibrary;
                if (EditorGUI.EndChangeCheck())
                {
                    m_LookDevView.envLibrary = library;
                }

                DrawSeparator();
                DrawHeader(styles.sMisc);
                m_LookDevView.config.showBalls          = GUILayout.Toggle(m_LookDevView.config.showBalls, styles.sShowBalls, styles.sMenuItem);
                m_LookDevView.config.showControlWindows = GUILayout.Toggle(m_LookDevView.config.showControlWindows, styles.sShowControlWindows, styles.sMenuItem);
                EditorGUI.BeginChangeCheck();
                bool allowDifferentObjects = GUILayout.Toggle(m_LookDevView.config.allowDifferentObjects, styles.sAllowDifferentObjects, styles.sMenuItem);
                if (EditorGUI.EndChangeCheck())
                {
                    m_LookDevView.config.allowDifferentObjects = allowDifferentObjects;
                }
                if (GUILayout.Button(styles.sResyncObjects, styles.sMenuItem))
                {
                    m_LookDevView.config.ResynchronizeObjects();
                }
            }
            GUILayout.EndVertical();

            // Use mouse move so we get hover state correctly in the menu item rows
            if (Event.current.type == EventType.MouseMove)
            {
                Event.current.Use();
            }

            // Escape closes the window
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
            {
                editorWindow.Close();
                GUIUtility.ExitGUI();
            }
        }