コード例 #1
0
        public override void OnInspectorGUI()
        {
            UISelectField select = (this.target as UISelectField);

            this.serializedObject.Update();

            this.DrawOptionsArea();
            EditorGUILayout.Separator();
            UISelectFieldEditor.DrawStringPopup("Default option", select.options.ToArray(), select.value, OnDefaultOptionSelected);
            EditorGUILayout.PropertyField(this.m_DirectionProperty);
            EditorGUILayout.PropertyField(this.m_InteractableProperty, new GUIContent("Interactable"));
            EditorGUILayout.Separator();
            EditorGUILayout.PropertyField(this.m_ArrowComponentProperty, new GUIContent("Arrow Component"));
            EditorGUILayout.PropertyField(this.m_LabelComponentProperty, new GUIContent("Label Component"));
            EditorGUILayout.Separator();
            this.DrawSelectFieldLayotProperties();
            EditorGUILayout.Separator();
            this.DrawListLayoutProperties();
            EditorGUILayout.Separator();
            this.DrawListSeparatorLayoutProperties();
            EditorGUILayout.Separator();
            this.DrawOptionLayoutProperties();
            EditorGUILayout.Separator();
            this.DrawOptionBackgroundLayoutProperties();
            EditorGUILayout.Separator();
            EditorGUILayout.PropertyField(this.m_NavigationProperty);
            EditorGUILayout.Separator();
            EditorGUILayout.PropertyField(this.m_OnChangeProperty);

            this.serializedObject.ApplyModifiedProperties();
        }
コード例 #2
0
        /// <summary>
        /// Raises the default option selected event.
        /// </summary>
        /// <param name="value">Value.</param>
        private void OnDefaultOptionSelected(string value)
        {
            UISelectField select = (this.target as UISelectField);

            Undo.RecordObject(select, "Select Field default option changed.");
            select.SelectOption(value);
            EditorUtility.SetDirty(select);
        }
コード例 #3
0
    /// <summary>
    /// Trigger all event notification callbacks.
    /// </summary>

    protected void TriggerCallbacks()
    {
        current = this;

        if (EventDelegate.IsValid(onChange))
        {
            EventDelegate.Execute(onChange);
        }

        current = null;
    }
コード例 #4
0
ファイル: UISelectField.cs プロジェクト: raoted/UnityRPG
    /// <summary>
    /// Trigger all event notification callbacks.
    /// </summary>

    protected void TriggerCallbacks()
    {
        if (current != this)
        {
            UISelectField old = current;
            current = this;

            if (EventDelegate.IsValid(onChange))
            {
                EventDelegate.Execute(onChange);
            }

            current = old;
        }
    }
コード例 #5
0
        public void UpdateState(UISelectField.VisualState state, bool instant)
        {
            if (this.textComponent == null || !this.gameObject.activeInHierarchy || this.transitionType == TransitionType.None)
                return;

            Color color = this.colors.normalColor;
            //string triggername = this.animationTriggers.normalTrigger;

            // Prepare the state values
            switch (state)
            {
            case UISelectField.VisualState.Normal:
                color = this.colors.normalColor;
                break;
            case UISelectField.VisualState.Highlighted:
                color = this.colors.highlightedColor;
                break;
            case UISelectField.VisualState.Pressed:
                color = this.colors.pressedColor;
                break;
            case UISelectField.VisualState.Active:
                color = this.colors.activeColor;
                break;
            case UISelectField.VisualState.ActiveHighlighted:
                color = this.colors.activeHighlightedColor;
                break;
            case UISelectField.VisualState.ActivePressed:
                color = this.colors.activePressedColor;
                break;
            case UISelectField.VisualState.Disabled:
                color = this.colors.disabledColor;
                break;
            }

            // Do the transition
            switch (this.transitionType)
            {
                case TransitionType.CrossFade:
                    this.StartColorTween(color * this.colors.colorMultiplier, (instant ? true : (this.colors.fadeDuration == 0f)));
                    break;
                //case Selectable.Transition.Animation:
                //	this.TriggerAnimation(triggername);
                //	break;
            }
        }
コード例 #6
0
        /// <summary>
        /// Draws the options area.
        /// </summary>
        private void DrawOptionsArea()
        {
            UISelectField select = (this.target as UISelectField);

            // 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);
            }
        }
コード例 #7
0
        public override void OnInspectorGUI()
        {
            if (this.m_FoldoutStyle == null)
            {
                this.m_FoldoutStyle = new GUIStyle(EditorStyles.foldout);
                this.m_FoldoutStyle.normal.textColor = Color.black;
                this.m_FoldoutStyle.fontStyle        = FontStyle.Bold;
            }

            UISelectField select = (this.target as UISelectField);

            this.serializedObject.Update();

            this.DrawOptionsArea();
            EditorGUILayout.Separator();
            UISelectFieldEditor.DrawStringPopup("Default option", select.options.ToArray(), select.value, OnDefaultOptionSelected);
            EditorGUILayout.PropertyField(this.m_DirectionProperty);
            EditorGUILayout.PropertyField(this.m_InteractableProperty, new GUIContent("Interactable"));
            EditorGUILayout.Separator();
            EditorGUILayout.PropertyField(this.m_LabelTextProperty, new GUIContent("Label Text"));
            EditorGUILayout.Separator();
            this.DrawSelectFieldLayotProperties();
            EditorGUILayout.Separator();
            this.DrawListLayoutProperties();
            EditorGUILayout.Separator();
            this.DrawScrollRectProperties();
            EditorGUILayout.Separator();
            this.DrawListSeparatorLayoutProperties();
            EditorGUILayout.Separator();
            this.DrawOptionLayoutProperties();
            EditorGUILayout.Separator();
            this.DrawOptionBackgroundLayoutProperties();
            EditorGUILayout.Separator();
            EditorGUILayout.PropertyField(this.m_NavigationProperty);
            EditorGUILayout.Separator();
            EditorGUILayout.PropertyField(this.m_OnChangeProperty);

            this.serializedObject.ApplyModifiedProperties();
        }
コード例 #8
0
    void OnEnable()
    {
        SerializedProperty bit = serializedObject.FindProperty("bitmapFont");

        mType = (bit.objectReferenceValue != null) ? FontType.Bitmap : FontType.Dynamic;
        mList = target as UISelectField;

        if (mList.ambigiousFont == null)
        {
            mList.ambigiousFont = NGUISettings.ambigiousFont;
            mList.fontSize      = NGUISettings.fontSize;
            mList.fontStyle     = NGUISettings.fontStyle;
            EditorUtility.SetDirty(mList);
        }

        if (mList.atlas == null)
        {
            mList.atlas = NGUISettings.atlas;
            mList.listBackgroundSprite = NGUISettings.selectedSprite;
            mList.listHighlightSprite  = NGUISettings.selectedSprite;
            EditorUtility.SetDirty(mList);
        }
    }
コード例 #9
0
		public void UpdateState(UISelectField.VisualState state, bool instant)
		{
			if (this.targetGraphic == null || !this.gameObject.activeInHierarchy || this.transitionType == Selectable.Transition.None)
				return;
	
			Color color = this.colors.normalColor;
			Sprite newSprite = null;
			string triggername = this.animationTriggers.normalTrigger;
		
			// Prepare the state values
			switch (state)
			{
				case UISelectField.VisualState.Normal:
					color = this.colors.normalColor;
					newSprite = null;
					triggername = this.animationTriggers.normalTrigger;
					break;
				case UISelectField.VisualState.Highlighted:
					color = this.colors.highlightedColor;
					newSprite = this.spriteState.highlightedSprite;
					triggername = this.animationTriggers.highlightedTrigger;
					break;
				case UISelectField.VisualState.Pressed:
					color = this.colors.pressedColor;
					newSprite = this.spriteState.pressedSprite;
					triggername = this.animationTriggers.pressedTrigger;
					break;
				case UISelectField.VisualState.Active:
					color = this.colors.activeColor;
					newSprite = this.spriteState.activeSprite;
					triggername = this.animationTriggers.activeTrigger;
					break;
				case UISelectField.VisualState.ActiveHighlighted:
					color = this.colors.activeHighlightedColor;
					newSprite = this.spriteState.activeHighlightedSprite;
					triggername = this.animationTriggers.activeHighlightedTrigger;
					break;
				case UISelectField.VisualState.ActivePressed:
					color = this.colors.activePressedColor;
					newSprite = this.spriteState.activePressedSprite;
					triggername = this.animationTriggers.activePressedTrigger;
					break;
				case UISelectField.VisualState.Disabled:
					color = this.colors.disabledColor;
					newSprite = this.spriteState.disabledSprite;
					triggername = this.animationTriggers.disabledTrigger;
					break;
			}
			
			// Do the transition
			switch (this.transitionType)
			{
				case Selectable.Transition.ColorTint:
					this.StartColorTween(color * this.colors.colorMultiplier, (instant ? true : (this.colors.fadeDuration == 0f)));
					break;
				case Selectable.Transition.SpriteSwap:
					this.DoSpriteSwap(newSprite);
					break;
				case Selectable.Transition.Animation:
					this.TriggerAnimation(triggername);
					break;
			}
		}
コード例 #10
0
		public void UpdateState(UISelectField.VisualState state)
		{
			this.UpdateState(state, false);
		}