Andrem
3 年前
当前提交
c81d59ae
共有 3 个文件被更改,包括 82 次插入 和 4 次删除
-
8Assets/Scripts/Effects/GlobalVolumeFeature.cs
-
67Assets/Scripts/Editor/GlobalVolumeFeatureEditor.cs
-
11Assets/Scripts/Editor/GlobalVolumeFeatureEditor.cs.meta
|
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEditor; |
|||
using UnityEngine; |
|||
using UnityEngine.Rendering; |
|||
|
|||
[CustomEditor(typeof(GlobalVolumeFeature))] |
|||
public class GlobalVolumeFeatureEditor : Editor |
|||
{ |
|||
private GlobalVolumeFeature feature; |
|||
private SerializedProperty profileList; |
|||
private SerializedProperty baseProfile; |
|||
|
|||
private static class Styles |
|||
{ |
|||
public static GUIStyle frameBox = new GUIStyle(EditorStyles.helpBox); |
|||
public static GUIStyle header = new GUIStyle(EditorStyles.boldLabel); |
|||
|
|||
public static GUIContent baseGUI = new GUIContent("Global Base Profile", |
|||
"This Profile is always active and should be treated as a default global settings for Volumes."); |
|||
} |
|||
|
|||
private void OnEnable() |
|||
{ |
|||
profileList = serializedObject.FindProperty(nameof(feature._qualityProfiles)); |
|||
baseProfile = serializedObject.FindProperty(nameof(feature._baseProfile)); |
|||
} |
|||
|
|||
public override void OnInspectorGUI() |
|||
{ |
|||
feature = (GlobalVolumeFeature)target; |
|||
|
|||
EditorGUILayout.PropertyField(baseProfile, Styles.baseGUI); |
|||
|
|||
EditorGUILayout.LabelField("Quality Level Profiles", Styles.header); |
|||
|
|||
var qualityLevelNames = QualitySettings.names; |
|||
|
|||
EditorGUILayout.BeginVertical(Styles.frameBox); |
|||
// Draw Quality level entries
|
|||
for (var i = 0; i < qualityLevelNames.Length; i++) |
|||
{ |
|||
if (i >= feature._qualityProfiles.Count) |
|||
{ |
|||
feature._qualityProfiles.Add(null); |
|||
EditorUtility.SetDirty(feature); |
|||
serializedObject.Update(); |
|||
} |
|||
EditorGUI.BeginChangeCheck(); |
|||
var obj = feature._qualityProfiles[i]; |
|||
feature._qualityProfiles[i] = (VolumeProfile)EditorGUILayout.ObjectField(qualityLevelNames[i], obj, typeof(VolumeProfile), false); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
EditorUtility.SetDirty(feature); |
|||
serializedObject.Update(); |
|||
} |
|||
} |
|||
EditorGUILayout.EndVertical(); |
|||
|
|||
if (qualityLevelNames.Length < feature._qualityProfiles.Count) |
|||
{ |
|||
feature._qualityProfiles.RemoveRange(qualityLevelNames.Length, feature._qualityProfiles.Count - qualityLevelNames.Length); |
|||
EditorUtility.SetDirty(feature); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 234cf3565ca2a49dc860867404243203 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue