Exemple #1
0
        /// <summary>
        /// Raises the default option selected event.
        /// </summary>
        /// <param name="value">Value.</param>
        private void OnDefaultOptionSelected(string value)
        {
            UISwitchSelect select = (this.target as UISwitchSelect);

            Undo.RecordObject(select, "Select Field default option changed.");
            select.SelectOption(value);
            EditorUtility.SetDirty(select);
        }
Exemple #2
0
        /// <summary>
        /// Draws the options area.
        /// </summary>
        private void DrawOptionsArea()
        {
            UISwitchSelect select = (this.target as UISwitchSelect);

            // Place a label for the options
            EditorGUILayout.LabelField("Options", EditorStyles.boldLabel);

            // Prepare the string to be used in the text area
            string text = "";

            foreach (string s in select.options)
            {
                text += s + "\n";
            }

            string modified = EditorGUILayout.TextArea(text, GUI.skin.textArea, GUILayout.Height(100f));

            // Check if the options have changed
            if (!modified.Equals(text))
            {
                Undo.RecordObject(target, "UI Select Field changed.");

                string[] split = modified.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries);

                select.options.Clear();

                foreach (string s in split)
                {
                    select.options.Add(s);
                }

                if (string.IsNullOrEmpty(select.value) || !select.options.Contains(select.value))
                {
                    select.value = select.options.Count > 0 ? select.options[0] : "";
                }

                EditorUtility.SetDirty(target);
            }
        }
Exemple #3
0
        public override void OnInspectorGUI()
        {
            UISwitchSelect select = (this.target as UISwitchSelect);

            this.serializedObject.Update();

            EditorGUILayout.Separator();
            EditorGUILayout.PropertyField(this.m_Text, new GUIContent("Label Text"));
            EditorGUILayout.PropertyField(this.m_PrevButton, new GUIContent("Prev Button"));
            EditorGUILayout.PropertyField(this.m_NextButton, new GUIContent("Next Button"));

            EditorGUILayout.Separator();
            this.DrawOptionsArea();

            EditorGUILayout.Separator();
            UISelectFieldEditor.DrawStringPopup("Selected option", select.options.ToArray(), select.value, OnDefaultOptionSelected);

            EditorGUILayout.Separator();
            EditorGUILayout.PropertyField(this.m_OnChange);

            this.serializedObject.ApplyModifiedProperties();
        }