-
-
Notifications
You must be signed in to change notification settings - Fork 316
Expand file tree
/
Copy pathUISoftMaskProjectSettingsEditor.cs
More file actions
85 lines (73 loc) · 3.43 KB
/
UISoftMaskProjectSettingsEditor.cs
File metadata and controls
85 lines (73 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using Coffee.UISoftMaskInternal;
using UnityEditor;
using UnityEngine;
namespace Coffee.UISoftMask
{
[CustomEditor(typeof(UISoftMaskProjectSettings))]
internal class UISoftMaskProjectSettingsEditor : Editor
{
private ShaderVariantRegistryEditor _shaderVariantRegistryEditor;
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUIUtility.labelWidth = 180;
// Setting
EditorGUILayout.LabelField("Setting", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_SoftMaskEnabled"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_StereoEnabled"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_TransformSensitivity"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_SoftMaskable"));
// Editor
EditorGUILayout.Space();
EditorGUILayout.LabelField("Editor", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_HideGeneratedComponents"));
// Shader registry.
EditorGUILayout.Space();
EditorGUILayout.LabelField("Shader", EditorStyles.boldLabel);
if (_shaderVariantRegistryEditor == null)
{
var property = serializedObject.FindProperty("m_ShaderVariantRegistry");
_shaderVariantRegistryEditor = new ShaderVariantRegistryEditor(property, "(SoftMaskable)",
() =>
{
UISoftMaskProjectSettings.shaderRegistry
.RegisterOptionalShaders(UISoftMaskProjectSettings.instance);
});
}
_shaderVariantRegistryEditor.Draw();
// Advanced
EditorGUILayout.Space();
EditorGUILayout.LabelField("Advanced", EditorStyles.boldLabel);
var excludeProp = serializedObject.FindProperty("m_ExcludeFromPreloadedAssetsWhenBuildPlayer");
EditorGUILayout.PropertyField(excludeProp);
if (excludeProp.boolValue)
{
var shadersProp = serializedObject.FindProperty("m_ShaderVariantRegistry")
.FindPropertyRelative("m_RegisteredShaders");
EditorGUI.BeginDisabledGroup(true);
EditorGUI.indentLevel++;
for (var i = 0; i < shadersProp.arraySize; i++)
{
EditorGUILayout.PropertyField(shadersProp.GetArrayElementAtIndex(i), GUIContent.none);
}
EditorGUI.indentLevel--;
EditorGUI.EndDisabledGroup();
if (shadersProp.arraySize == 0)
{
EditorGUILayout.HelpBox(
"No shaders registered. Re-import or modify the settings asset to trigger sync.",
MessageType.Warning);
}
}
serializedObject.ApplyModifiedProperties();
// Upgrade All Assets For V3.
EditorGUILayout.Space();
EditorGUILayout.LabelField("Upgrade", EditorStyles.boldLabel);
if (GUILayout.Button("Upgrade All Assets For V3"))
{
EditorApplication.delayCall += () => new UISoftMaskModifierRunner().RunIfUserWantsTo();
}
GUILayout.FlexibleSpace();
}
}
}