private bool DrawPreviewButton(SimpleMenuCollectionButton template, bool showText) { bool drewButton = false; if (template.IsEmpty) { return(drewButton); } if (buttonPreviewStyle == null) { buttonPreviewStyle = new GUIStyle(EditorStyles.toolbarButton); buttonPreviewStyle.fontSize = 12; buttonPreviewStyle.fixedHeight = previewButtonSizeY; buttonPreviewStyle.fixedWidth = previewButtonSizeX; } drewButton = true; GUI.color = Color.white; GUILayout.Button(showText ? template.Text : template.Name, buttonPreviewStyle); GUI.color = HUXEditorUtils.DefaultColor; return(drewButton); }
private void DrawButtonEditor(SimpleMenuCollectionButton template, bool showIcon, bool showText, ButtonIconProfile profile, string arrayName, int templateIndex, HashSet <string> buttonNamesSoFar) { if (!string.IsNullOrEmpty(template.Name)) { HUXEditorUtils.BeginSectionBox(template.Name + " (" + template.Index + ")", HUXEditorUtils.ObjectColor); } else { HUXEditorUtils.BeginSectionBox(string.Empty, HUXEditorUtils.ObjectColorEmpty); } GUI.color = template.IsEmpty ? HUXEditorUtils.DisabledColor : HUXEditorUtils.DefaultColor; EditorGUILayout.BeginHorizontal(); template.Name = EditorGUILayout.TextField(string.IsNullOrEmpty(template.Name) ? "Button Name (Empty)" : "Button Name", template.Name); if (GUILayout.Button("Clear", EditorStyles.miniButton)) { template.Name = string.Empty; } EditorGUILayout.EndHorizontal(); if (!string.IsNullOrEmpty(template.Name) && buttonNamesSoFar.Contains(template.Name)) { HUXEditorUtils.ErrorMessage("Buttons must have unique names."); } else { buttonNamesSoFar.Add(template.Name); } if (!template.IsEmpty) { if (showText) { if (string.IsNullOrEmpty(template.Text)) { GUI.color = HUXEditorUtils.WarningColor; } template.Text = EditorGUILayout.TextField("Label Text", template.Text); } if (showIcon) { 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]; } if (!Application.isPlaying) { template.Target = HUXEditorUtils.SceneObjectField <InteractionReceiver>("Interaction Receiver", template.Target); if (template.Target == 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(); }