9using System.Collections;
10using System.Collections.Generic;
17 [CustomPropertyDrawer(typeof(LeapMesherBase), useForChildren:
true)]
19 private const float HEADER_HEADROOM = 8;
20 private const float MESH_LABEL_WIDTH = 100.0f;
21 private const float REFRESH_BUTTON_WIDTH = 100;
23 private static float SHADER_WARNING_HEIGHT = 40;
24 private static float SHADER_WARNING_FIX_WIDTH = 50;
26 private SerializedProperty _uv0, _uv1, _uv2, _uv3, _colors, _bakedTint, _normals;
28 protected override void init(SerializedProperty property) {
31 _uv0 =
property.FindPropertyRelative(
"_useUv0");
32 _uv1 =
property.FindPropertyRelative(
"_useUv1");
33 _uv2 =
property.FindPropertyRelative(
"_useUv2");
34 _uv3 =
property.FindPropertyRelative(
"_useUv3");
35 _colors =
property.FindPropertyRelative(
"_useColors");
36 _bakedTint =
property.FindPropertyRelative(
"_bakedTint");
37 _normals =
property.FindPropertyRelative(
"_useNormals");
40 rect.y += HEADER_HEADROOM;
41 EditorGUI.LabelField(rect,
"Mesh Settings", EditorStyles.boldLabel);
42 }, HEADER_HEADROOM + EditorGUIUtility.singleLineHeight);
48 rect.SplitHorizontally(out left, out right);
49 EditorGUI.PropertyField(left, _uv0);
50 EditorGUI.PropertyField(right, _uv1);
51 }, EditorGUIUtility.singleLineHeight);
55 rect.SplitHorizontally(out left, out right);
56 EditorGUI.PropertyField(left, _uv2);
57 EditorGUI.PropertyField(right, _uv3);
58 }, EditorGUIUtility.singleLineHeight);
62 rect.SplitHorizontally(out left, out right);
63 EditorGUI.PropertyField(left, _colors);
64 if (_colors.boolValue) {
65 EditorGUI.PropertyField(right, _bakedTint);
67 }, EditorGUIUtility.singleLineHeight);
71 rect.SplitHorizontally(out left, out right);
72 EditorGUI.PropertyField(left, _normals);
73 }, EditorGUIUtility.singleLineHeight);
78 rect.y += HEADER_HEADROOM;
79 rect.height = EditorGUIUtility.singleLineHeight;
80 EditorGUI.LabelField(rect,
"Rendering Settings", EditorStyles.boldLabel);
81 }, HEADER_HEADROOM + EditorGUIUtility.singleLineHeight);
85 SerializedProperty shaderProp;
89 if (!shaderProp.hasMultipleDifferentValues) {
90 Shader shader = shaderProp.objectReferenceValue as Shader;
91 if (VariantEnabler.DoesShaderHaveVariantsDisabled(shader)) {
93 rect.SplitHorizontallyWithRight(out left, out right, SHADER_WARNING_FIX_WIDTH);
95 EditorGUI.HelpBox(left,
"This shader has disabled variants, and will not function until they are enabled.", MessageType.Warning);
96 if (GUI.Button(right,
"Enable")) {
97 if (EditorUtility.DisplayDialog(
"Import Time Warning!",
"The import time for this surface shader can take up to 2-3 minutes! Are you sure you want to enable?",
"Enable",
"Not right now")) {
98 VariantEnabler.SetShaderVariantsEnabled(shader, enable: true);
99 AssetDatabase.Refresh();
106 Shader shader = shaderProp.objectReferenceValue as Shader;
107 if (VariantEnabler.DoesShaderHaveVariantsDisabled(shader)) {
108 return SHADER_WARNING_HEIGHT;
115 drawProperty(
"_visualLayer", includeChildren:
true, disable: EditorApplication.isPlaying);
116 drawProperty(
"_atlas", includeChildren:
true, disable: EditorApplication.isPlaying);
void drawProperty(string name, bool includeChildren=true, bool disable=false)
void drawCustom(Action< Rect > drawFunc, float height)
bool tryGetProperty(string name, out SerializedProperty property)
override void init(SerializedProperty property)