5 using System.Collections.Generic;
12 [Tooltip(
"Name of the shader color property that will be modified (default '_Color')")]
13 public string ColorPropertyName =
"_Color";
15 [Tooltip(
"Name of the shader float property that will be modified.")]
16 public string ValuePropertyName =
string.Empty;
18 [Tooltip(
"If true, button properties are lerped instead of instantaneous.")]
19 public bool SmoothStateChanges =
false;
21 [Tooltip(
"Whether to hold pressed events for a short period.")]
22 public bool StickyPressedEvents =
false;
24 [Tooltip(
"How long to hold sticky pressed events.")]
25 public float StickyPressedTime = 0.15f;
28 [Tooltip(
"How quickly to animate scale, offset, color and value properties")]
29 public float AnimationSpeed = 1f;
38 public class CustomEditor : ProfileInspector
43 protected override void DrawCustomFooter() {
48 meshButton = targetComponent as CompoundButtonMesh;
52 List<CompoundButtonMesh.MeshButtonDatum> missingStates =
new List<CompoundButtonMesh.MeshButtonDatum>();
54 bool foundState =
false;
56 if (datum.ActiveState == buttonState) {
64 missingState.
Name = buttonState.ToString();
65 missingStates.Add(missingState);
71 if (missingStates.Count > 0) {
72 missingStates.AddRange(meshProfile.ButtonStates);
73 meshProfile.ButtonStates = missingStates.ToArray();
80 if (meshButton != null && meshButton.TargetTransform == null) {
81 UnityEditor.EditorGUILayout.LabelField(
"(No target transform specified for scale / offset)",
UnityEditor.EditorStyles.miniLabel);
83 datum.Offset =
UnityEditor.EditorGUILayout.Vector3Field(
"Offset", datum.Offset);
84 datum.Scale =
UnityEditor.EditorGUILayout.Vector3Field(
"Scale", datum.Scale);
86 if (datum.Scale == Vector3.zero) {
87 GUI.color = warningColor;
88 if (GUILayout.Button(
"Warning: Button state scale is zero. Click here to fix.",
UnityEditor.EditorStyles.miniButton)) {
89 datum.Scale = Vector3.one;
94 GUI.color = defaultColor;
95 if (meshButton != null && meshButton.Renderer == null) {
96 UnityEditor.EditorGUILayout.LabelField(
"(No target renderer specified for color / value material properties)",
UnityEditor.EditorStyles.miniLabel);
98 if (!
string.IsNullOrEmpty(meshProfile.ColorPropertyName)) {
99 datum.StateColor =
UnityEditor.EditorGUILayout.ColorField(meshProfile.ColorPropertyName +
" value", datum.StateColor);
101 if (!
string.IsNullOrEmpty(meshProfile.ValuePropertyName)) {
102 datum.StateValue =
UnityEditor.EditorGUILayout.FloatField(meshProfile.ValuePropertyName +
" value", datum.StateValue);