Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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();
        }