private AppBar.ButtonTemplate DrawButtonEditor(AppBar.ButtonTemplate template, ButtonIconProfile profile, ref int numCustomButtons, string arrayName, int templateIndex) { // Set the button's position immediately template.DefaultPosition = 0; if (!template.IsEmpty) { numCustomButtons++; template.DefaultPosition = numCustomButtons; } HUXEditorUtils.BeginSectionBox(template.IsEmpty ? "(Empty)" : template.Name + " (" + template.DefaultPosition + ")", HUXEditorUtils.ObjectColor); template.Type = AppBar.ButtonTypeEnum.Custom; GUI.color = template.IsEmpty ? HUXEditorUtils.DisabledColor : HUXEditorUtils.DefaultColor; EditorGUILayout.BeginHorizontal(); template.Name = EditorGUILayout.TextField("Button Name", template.Name); if (GUILayout.Button("Clear", EditorStyles.miniButton)) { template.Name = string.Empty; } EditorGUILayout.EndHorizontal(); if (!template.IsEmpty) { if (string.IsNullOrEmpty(template.Text)) { GUI.color = HUXEditorUtils.WarningColor; } template.Text = EditorGUILayout.TextField("Label Text", template.Text); GUI.color = HUXEditorUtils.DefaultColor; string[] keys = profile.GetIconKeys().ToArray(); int selectedIndex = 0; for (int i = 0; i < keys.Length; i++) { if (keys[i].Equals(template.Icon)) { selectedIndex = i; break; } } selectedIndex = EditorGUILayout.Popup("Icon", selectedIndex, keys); template.Icon = keys[selectedIndex]; template.EventTarget = HUXEditorUtils.SceneObjectField <InteractionReceiver>("Interaction Receiver", template.EventTarget); if (template.EventTarget == null) { HUXEditorUtils.WarningMessage("This button will have no effect until you choose an interaction receiver to register it with."); } } // Draw the unity message section /*string propertyName = string.Format("{0}.Array.data[{1}].OnTappedEvent", arrayName, templateIndex); * SerializedProperty buttonEvent = serializedObject.FindProperty(propertyName); * EditorGUILayout.PropertyField(buttonEvent); * if (GUI.changed) { * serializedObject.ApplyModifiedProperties(); * }*/ HUXEditorUtils.EndSectionBox(); return(template); }
private bool DrawPreviewButton(AppBar.ButtonTemplate template, AppBar.AppBarStateEnum state, bool useHide, bool useAdjust, bool useRemove) { bool drewButton = false; if (template.IsEmpty) { return(drewButton); } if (buttonPreviewStyle == null) { buttonPreviewStyle = new GUIStyle(EditorStyles.toolbarButton); buttonPreviewStyle.fontSize = 8; buttonPreviewStyle.fixedHeight = previewButtonSize; buttonPreviewStyle.fixedWidth = previewButtonSize; } GUI.color = Color.Lerp(Color.gray, HUXEditorUtils.DefaultColor, 0.5f); switch (state) { case AppBar.AppBarStateEnum.Default: switch (template.Type) { case AppBar.ButtonTypeEnum.Custom: GUILayout.Button(template.Text, buttonPreviewStyle); drewButton = true; break; case AppBar.ButtonTypeEnum.Adjust: if (useAdjust) { GUILayout.Button(template.Text, buttonPreviewStyle); drewButton = true; } break; case AppBar.ButtonTypeEnum.Hide: if (useHide) { GUILayout.Button(template.Text, buttonPreviewStyle); drewButton = true; } break; case AppBar.ButtonTypeEnum.Remove: if (useRemove) { GUILayout.Button(template.Text, buttonPreviewStyle); drewButton = true; } break; default: break; } break; case AppBar.AppBarStateEnum.Hidden: switch (template.Type) { case AppBar.ButtonTypeEnum.Show: if (useHide) { GUILayout.Button(template.Text, buttonPreviewStyle); drewButton = true; } break; default: break; } break; case AppBar.AppBarStateEnum.Manipulation: switch (template.Type) { default: break; case AppBar.ButtonTypeEnum.Done: GUILayout.Button(template.Text, buttonPreviewStyle); drewButton = true; break; case AppBar.ButtonTypeEnum.Remove: if (useRemove) { GUILayout.Button(template.Text, buttonPreviewStyle); drewButton = true; } break; } break; } GUI.color = HUXEditorUtils.DefaultColor; return(drewButton); }