Exemplo n.º 1
0
        static void Drawer_VolumeSection(SerializedHDRenderPipelineGlobalSettings serialized, Editor owner)
        {
            using (new EditorGUI.IndentLevelScope())
            {
                var oldWidth = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = Styles.labelWidth;

                HDRenderPipelineGlobalSettings globalSettings = serialized.serializedObject.targetObject as HDRenderPipelineGlobalSettings;
                VolumeProfile asset = null;
                using (new EditorGUILayout.HorizontalScope())
                {
                    var oldAssetValue = serialized.volumeProfileDefault.objectReferenceValue;
                    EditorGUILayout.PropertyField(serialized.volumeProfileDefault, Styles.defaultVolumeProfileLabel);
                    asset = serialized.volumeProfileDefault.objectReferenceValue as VolumeProfile;
                    if (asset == null && oldAssetValue != null)
                    {
                        Debug.Log("Default Volume Profile Asset cannot be null. Rolling back to previous value.");
                        serialized.volumeProfileDefault.objectReferenceValue = oldAssetValue;
                    }

                    if (GUILayout.Button(EditorGUIUtility.TrTextContent("New", "Create a new Volume Profile for default in your default resource folder (defined in Wizard)"), GUILayout.Width(38), GUILayout.Height(18)))
                    {
                        HDAssetFactory.VolumeProfileCreator.CreateAndAssign(HDAssetFactory.VolumeProfileCreator.Kind.Default, globalSettings);
                    }
                }
                if (asset != null)
                {
                    // The state of the profile can change without the asset reference changing so in this case we need to reset the editor.
                    if (m_CurrentVolumeProfileInstanceID != asset.GetInstanceID() && m_CachedDefaultVolumeProfileEditor != null)
                    {
                        m_CurrentVolumeProfileInstanceID   = asset.GetInstanceID();
                        m_CachedDefaultVolumeProfileEditor = null;
                    }

                    Editor.CreateCachedEditor(asset, Type.GetType("UnityEditor.Rendering.VolumeProfileEditor"), ref m_CachedDefaultVolumeProfileEditor);
                    bool oldEnabled = GUI.enabled;
                    GUI.enabled = AssetDatabase.IsOpenForEdit(asset);
                    m_CachedDefaultVolumeProfileEditor.OnInspectorGUI();
                    GUI.enabled = oldEnabled;
                }

                EditorGUILayout.Space();

                VolumeProfile lookDevAsset = null;
                using (new EditorGUILayout.HorizontalScope())
                {
                    var oldAssetValue = serialized.volumeProfileLookDev.objectReferenceValue;
                    EditorGUILayout.PropertyField(serialized.volumeProfileLookDev, Styles.lookDevVolumeProfileLabel);
                    lookDevAsset = serialized.volumeProfileLookDev.objectReferenceValue as VolumeProfile;
                    if (lookDevAsset == null && oldAssetValue != null)
                    {
                        Debug.Log("LookDev Volume Profile Asset cannot be null. Rolling back to previous value.");
                        serialized.volumeProfileLookDev.objectReferenceValue = oldAssetValue;
                    }

                    if (GUILayout.Button(EditorGUIUtility.TrTextContent("New", "Create a new Volume Profile for default in your default resource folder (defined in Wizard)"), GUILayout.Width(38), GUILayout.Height(18)))
                    {
                        HDAssetFactory.VolumeProfileCreator.CreateAndAssign(HDAssetFactory.VolumeProfileCreator.Kind.LookDev, globalSettings);
                    }
                }
                if (lookDevAsset != null)
                {
                    Editor.CreateCachedEditor(lookDevAsset, Type.GetType("UnityEditor.Rendering.VolumeProfileEditor"), ref m_CachedLookDevVolumeProfileEditor);
                    bool oldEnabled = GUI.enabled;
                    GUI.enabled = AssetDatabase.IsOpenForEdit(lookDevAsset);
                    m_CachedLookDevVolumeProfileEditor.OnInspectorGUI();
                    GUI.enabled = oldEnabled;

                    if (lookDevAsset.Has <VisualEnvironment>())
                    {
                        EditorGUILayout.HelpBox("VisualEnvironment is not modifiable and will be overridden by the LookDev", MessageType.Warning);
                    }
                    if (lookDevAsset.Has <HDRISky>())
                    {
                        EditorGUILayout.HelpBox("HDRISky is not modifiable and will be overridden by the LookDev", MessageType.Warning);
                    }
                }
                EditorGUIUtility.labelWidth = oldWidth;
            }
        }