in Assets/MixedRealityToolkit.SDK/Inspectors/UX/Interactable/ThemeInspector.cs [765:999]
public static void RenderThemeSettings(SerializedProperty themeSettings, SerializedObject themeObj, InteractableTypesContainer themeOptions, SerializedProperty gameObject, int[] listIndex, State[] states)
{
GUIStyle box = InspectorUIUtility.Box(0);
if (themeObj != null)
{
box = InspectorUIUtility.Box(30);
themeObj.Update();
}
for (int n = 0; n < themeSettings.arraySize; n++)
{
SerializedProperty settingsItem = themeSettings.GetArrayElementAtIndex(n);
SerializedProperty className = settingsItem.FindPropertyRelative("Name");
EditorGUI.indentLevel = indentOnSectionStart;
EditorGUILayout.BeginVertical(box);
// a dropdown for the type of theme, they should make sense
// show theme dropdown
int id = InspectorUIUtility.ReverseLookup(className.stringValue, themeOptions.ClassNames);
EditorGUILayout.BeginHorizontal();
int newId = EditorGUILayout.Popup("Theme Property", id, themeOptions.ClassNames);
if (n > 0)
{
// standalone or inside a profile? if(listIndex[1] < 1)
if (listIndex[1] < 0)
{
listIndex[2] = n;
}
bool removed = InspectorUIUtility.SmallButton(new GUIContent(InspectorUIUtility.Minus, "Remove Theme Property"), listIndex, RemoveThemeProperty, themeSettings);
if (removed)
{
continue;
}
}
EditorGUILayout.EndHorizontal();
if (id != newId)
{
SerializedProperty assemblyQualifiedName = settingsItem.FindPropertyRelative("AssemblyQualifiedName");
className.stringValue = themeOptions.ClassNames[newId];
assemblyQualifiedName.stringValue = themeOptions.AssemblyQualifiedNames[newId];
// add the themeOjects if in a profile?
//themeObj = ChangeThemeProperty(n, themeObj, gameObject);
themeSettings = ChangeThemeProperty(n, themeSettings, gameObject, states);
}
SerializedProperty sProps = settingsItem.FindPropertyRelative("Properties");
EditorGUI.indentLevel = indentOnSectionStart + 1;
int animatorCount = 0;
int idCount = 0;
for (int p = 0; p < sProps.arraySize; p++)
{
SerializedProperty item = sProps.GetArrayElementAtIndex(p);
SerializedProperty propId = item.FindPropertyRelative("PropId");
SerializedProperty name = item.FindPropertyRelative("Name");
SerializedProperty shaderNames = item.FindPropertyRelative("ShaderOptionNames");
SerializedProperty shaderName = item.FindPropertyRelative("ShaderName");
SerializedProperty propType = item.FindPropertyRelative("Type");
InteractableThemePropertyValueTypes type = (InteractableThemePropertyValueTypes)propType.intValue;
if (type == InteractableThemePropertyValueTypes.AnimatorTrigger)
{
animatorCount++;
}
bool hasTextComp = false;
if (shaderNames.arraySize > 0)
{
// show shader property dropdown
if (idCount < 1)
{
GUILayout.Space(5);
}
string[] shaderOptionNames = InspectorUIUtility.GetOptions(shaderNames);
string propName = shaderOptionNames[propId.intValue];
bool hasShaderProperty = true;
if (gameObject == null)
{
EditorGUILayout.LabelField(new GUIContent("Shader: " + shaderName.stringValue));
}
else
{
GameObject renderHost = gameObject.objectReferenceValue as GameObject;
if (renderHost != null)
{
Renderer renderer = renderHost.GetComponent<Renderer>();
TextMesh mesh = renderHost.GetComponent<TextMesh>();
Text text = renderHost.GetComponent<Text>();
hasTextComp = text != null || mesh != null;
if (renderer != null && !hasTextComp)
{
ShaderPropertyType[] filter = new ShaderPropertyType[0];
switch (type)
{
case InteractableThemePropertyValueTypes.Color:
filter = new ShaderPropertyType[] { ShaderPropertyType.Color };
break;
case InteractableThemePropertyValueTypes.ShaderFloat:
filter = new ShaderPropertyType[] { ShaderPropertyType.Float };
break;
case InteractableThemePropertyValueTypes.shaderRange:
filter = new ShaderPropertyType[] { ShaderPropertyType.Float };
break;
default:
break;
}
ShaderInfo info = GetShaderProperties(renderer, filter);
if (info.Name != shaderName.stringValue)
{
hasShaderProperty = false;
for (int i = 0; i < info.ShaderOptions.Length; i++)
{
if (info.ShaderOptions[i].Name == propName)
{
hasShaderProperty = true;
break;
}
}
}
}
}
}
if (!hasTextComp)
{
GUIStyle popupStyle = new GUIStyle(EditorStyles.popup);
popupStyle.margin.right = Mathf.RoundToInt(Screen.width - (Screen.width - 40));
propId.intValue = EditorGUILayout.Popup("Material " + name.stringValue + "Id", propId.intValue, shaderOptionNames, popupStyle);
idCount++;
if (!hasShaderProperty)
{
InspectorUIUtility.DrawError(propName + " is not available on the currently assigned Material.");
}
}
else
{
EditorGUILayout.LabelField(new GUIContent("Text Property: " + (InteractableThemePropertyValueTypes)propId.intValue));
}
// Handle issue where the material color id renders on objects it shouldn't!!!!!!!!!!!!!!
// theme is save for a game object with a renderer, but when put on a textmesh, rendering prop values show up.
// when changing the theme type on a TextMesh, everything works, but the rendering prop is removed from the theme on the renderer object.
// make this passive, only show up when needed.
}
}
EditorGUI.indentLevel = indentOnSectionStart;
GUILayout.Space(5);
if (animatorCount < sProps.arraySize)
{
// show theme properties
SerializedProperty easing = settingsItem.FindPropertyRelative("Easing");
SerializedProperty enabled = easing.FindPropertyRelative("Enabled");
SerializedProperty noEasing = settingsItem.FindPropertyRelative("NoEasing");
if (!noEasing.boolValue)
{
InspectorUIUtility.DrawDivider();
enabled.boolValue = EditorGUILayout.Toggle(new GUIContent("Easing", "should the theme animate state values"), enabled.boolValue);
if (enabled.boolValue)
{
EditorGUI.indentLevel = indentOnSectionStart + 1;
SerializedProperty time = easing.FindPropertyRelative("LerpTime");
SerializedProperty curve = easing.FindPropertyRelative("Curve");
time.floatValue = EditorGUILayout.FloatField(new GUIContent("Duration", "animation duration"), time.floatValue);
EditorGUILayout.PropertyField(curve, new GUIContent("Animation Curve"));
EditorGUI.indentLevel = indentOnSectionStart;
}
}
else
{
enabled.boolValue = false;
}
}
// check to see if an animatorController exists
if (animatorCount > 0 && gameObject != null)
{
GameObject host = gameObject.objectReferenceValue as GameObject;
Animator animator = null;
if (host != null)
{
animator = host.GetComponent<Animator>();
}
if (animator == null && host != null)
{
SerializedProperty targetInfo = settingsItem.FindPropertyRelative("ThemeTarget");
SerializedProperty targetStates = targetInfo.FindPropertyRelative("States");
targetStates = GetSerializedStates(targetStates, states);
#pragma warning disable 0219 // disable value is never used warning
//assigning values to be passed to the FlexButton
SerializedProperty target = targetInfo.FindPropertyRelative("Target");
SerializedProperty props = targetInfo.FindPropertyRelative("Properties");
target = gameObject;
props = sProps;
#pragma warning restore 0219 // enable value is never used warning
InspectorUIUtility.FlexButton(new GUIContent("Create Animations", "Create and add an Animator with AnimationClips"), listIndex, AddAnimator, targetInfo);
}
}
EditorGUILayout.EndVertical();
if (themeObj != null)
{
themeObj.ApplyModifiedProperties();
}
}
}