in Assets/MRTK/SDK/Editor/Inspectors/UX/Interactable/ButtonConfigHelperInspector.cs [76:295]
public override void OnInspectorGUI()
{
cb = (ButtonConfigHelper)target;
bool labelFoldout = SessionState.GetBool(LabelFoldoutKey, true);
bool basicEventsFoldout = SessionState.GetBool(BasicEventsFoldoutKey, true);
bool iconFoldout = SessionState.GetBool(IconFoldoutKey, true);
bool showComponents = SessionState.GetBool(ShowComponentsKey, false);
bool showSpeechCommand = SessionState.GetBool(ShowSpeechCommandKey, true);
if (cb.EditorCheckForCustomIcon())
{
using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
{
EditorGUILayout.LabelField("Custom Icon Migration", EditorStyles.boldLabel);
EditorGUILayout.HelpBox(customIconUpgradeMessage, MessageType.Error);
using (new EditorGUILayout.HorizontalScope())
{
if (GUILayout.Button("Use migration tool to upgrade buttons"))
{
if (!EditorApplication.ExecuteMenuItem("Mixed Reality/Toolkit/Utilities/Migration Window"))
{
EditorUtility.DisplayDialog("Package Required", "You need to install the MRTK tools (Microsoft.MixedRealityToolkit.Unity.Tools) package to use the Migration Tool", "OK");
}
}
InspectorUIUtility.RenderDocumentationButton(upgradeDocUrl);
}
}
}
showComponents = EditorGUILayout.Toggle("Show Component References", showComponents);
ButtonIconStyle oldStyle = (ButtonIconStyle)iconStyleProp.intValue;
using (new EditorGUI.IndentLevelScope(1))
{
using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
{
labelFoldout = EditorGUILayout.Foldout(labelFoldout, "Labels", true);
if (labelFoldout)
{
EditorGUI.BeginChangeCheck();
if (showComponents)
{
EditorGUILayout.PropertyField(mainLabelTextProp);
}
if (mainLabelTextProp.objectReferenceValue != null)
{
Component mainLabelText = (Component)mainLabelTextProp.objectReferenceValue;
bool mainLabelTextActive = EditorGUILayout.Toggle("Enable Main Label", mainLabelText.gameObject.activeSelf);
if (mainLabelText.gameObject.activeSelf != mainLabelTextActive)
{
mainLabelText.gameObject.SetActive(mainLabelTextActive);
EditorUtility.SetDirty(mainLabelText.gameObject);
}
if (mainLabelText.gameObject.activeSelf)
{
SerializedObject labelTextObject = new SerializedObject(mainLabelText);
SerializedProperty textProp = labelTextObject.FindProperty("m_text");
EditorGUILayout.PropertyField(textProp, new GUIContent("Main Label Text"));
EditorGUILayout.Space();
if (EditorGUI.EndChangeCheck())
{
labelTextObject.ApplyModifiedProperties();
}
}
}
if (showComponents)
{
EditorGUILayout.PropertyField(seeItSayItLabelProp);
}
if (seeItSayItLabelProp.objectReferenceValue != null)
{
GameObject seeItSayItLabel = (GameObject)seeItSayItLabelProp.objectReferenceValue;
bool seeItSayItLabelActive = EditorGUILayout.Toggle("Enable See it / Say it Label", seeItSayItLabel.activeSelf);
if (seeItSayItLabel.activeSelf != seeItSayItLabelActive)
{
seeItSayItLabel.SetActive(seeItSayItLabelActive);
EditorUtility.SetDirty(seeItSayItLabel);
}
if (seeItSayItLabel.activeSelf)
{
var sisiChanged = false;
EditorGUI.BeginChangeCheck();
if (showComponents)
{
EditorGUILayout.PropertyField(seeItSayItLabelTextProp);
}
showSpeechCommand = EditorGUILayout.Toggle("Display Speech Command", showSpeechCommand);
SerializedObject sisiLabelTextObject = new SerializedObject(seeItSayItLabelTextProp.objectReferenceValue);
SerializedProperty sisiTextProp = sisiLabelTextObject.FindProperty("m_text");
if (!showSpeechCommand)
{
EditorGUILayout.PropertyField(sisiTextProp, new GUIContent("See it / Say it Label"));
EditorGUILayout.Space();
}
else
{
if (interactableProp.objectReferenceValue != null)
{
SerializedObject interactableObject = new SerializedObject(interactableProp.objectReferenceValue);
SerializedProperty voiceCommandProperty = interactableObject.FindProperty("voiceCommand");
if(string.IsNullOrEmpty(voiceCommandProperty.stringValue))
{
EditorGUILayout.HelpBox("No valid speech command provided to the interactable", MessageType.Warning);
}
else
{
string sisiText = string.Format("Say \"{0}\"", voiceCommandProperty.stringValue);
if (sisiTextProp.stringValue != sisiText)
{
sisiTextProp.stringValue = sisiText;
sisiChanged = true;
}
}
}
else
{
EditorGUILayout.HelpBox("There is no interactable linked to the button config helper. One is needed to display the appropriate speech command", MessageType.Warning);
}
}
sisiChanged |= EditorGUI.EndChangeCheck();
if (sisiChanged)
{
sisiLabelTextObject.ApplyModifiedProperties();
}
}
}
}
}
}
using (new EditorGUI.IndentLevelScope(1))
{
using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
{
basicEventsFoldout = EditorGUILayout.Foldout(basicEventsFoldout, "Basic Events", true);
if (basicEventsFoldout)
{
EditorGUI.BeginChangeCheck();
if (showComponents)
{
EditorGUILayout.PropertyField(interactableProp);
}
if (interactableProp.objectReferenceValue != null)
{
SerializedObject interactableObject = new SerializedObject(interactableProp.objectReferenceValue);
SerializedProperty onClickProp = interactableObject.FindProperty("OnClick");
EditorGUILayout.PropertyField(onClickProp);
if (EditorGUI.EndChangeCheck())
{
interactableObject.ApplyModifiedProperties();
}
}
}
}
}
using (new EditorGUI.IndentLevelScope(1))
{
using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
{
iconFoldout = EditorGUILayout.Foldout(iconFoldout, "Icon", true);
ButtonIconSet iconSet = (ButtonIconSet)iconSetProp.objectReferenceValue;
if (iconFoldout)
{
EditorGUILayout.PropertyField(iconStyleProp);
switch (cb.IconStyle)
{
case ButtonIconStyle.Char:
DrawIconCharEditor(showComponents, iconSet);
break;
case ButtonIconStyle.Quad:
DrawIconQuadEditor(showComponents, iconSet);
break;
case ButtonIconStyle.Sprite:
DrawIconSpriteEditor(showComponents, iconSet);
break;
}
EditorGUILayout.Space();
}
}
}
SessionState.SetBool(LabelFoldoutKey, labelFoldout);
SessionState.SetBool(BasicEventsFoldoutKey, basicEventsFoldout);
SessionState.SetBool(IconFoldoutKey, iconFoldout);
SessionState.SetBool(ShowComponentsKey, showComponents);
SessionState.SetBool(ShowSpeechCommandKey, showSpeechCommand);
serializedObject.ApplyModifiedProperties();
if (oldStyle != (ButtonIconStyle)iconStyleProp.intValue)
{
cb.ForceRefresh();
}
}