public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
        {
            SerializedProperty navigation = prop.FindPropertyRelative("m_Mode");

            if (navigation == null)
            {
                return(EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
            }

            Navigation.Mode navMode = GetNavigationMode(navigation);

            switch (navMode)
            {
            case Navigation.Mode.None:
                return(EditorGUIUtility.singleLineHeight);

            case Navigation.Mode.Horizontal:
            case Navigation.Mode.Vertical:
                return(2 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing);

            case Navigation.Mode.Explicit:
                return(5 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing);

            default:
                return(EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
            }
        }
Exemple #2
0
        public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
        {
            SerializedProperty serializedProperty = prop.FindPropertyRelative("m_Mode");
            float result;

            if (serializedProperty == null)
            {
                result = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            }
            else
            {
                Navigation.Mode navigationMode = NavigationDrawer.GetNavigationMode(serializedProperty);
                if (navigationMode != Navigation.Mode.None)
                {
                    if (navigationMode != Navigation.Mode.Explicit)
                    {
                        result = EditorGUIUtility.singleLineHeight + 1f * EditorGUIUtility.standardVerticalSpacing;
                    }
                    else
                    {
                        result = 5f * EditorGUIUtility.singleLineHeight + 5f * EditorGUIUtility.standardVerticalSpacing;
                    }
                }
                else
                {
                    result = EditorGUIUtility.singleLineHeight;
                }
            }
            return(result);
        }
Exemple #3
0
    void Start()
    {
        if (SetScript == null)
        {
            SetScript = GetComponentInParent <jInputSettings>();
        }
        if (SetScript == null)
        {
            Debug.LogError("[jInput] jInputSettings script is Not Found!!");
        }

        if (ThisButton == null)
        {
            ThisButton = GetComponent <Button>();
        }
        if (ThisButton != null)
        {
            BaseHighlightedThisButtonColor = ThisButton.colors.highlightedColor;
            PrevNavMode = ThisButton.navigation.mode;
        }
        else
        {
            Debug.LogError("[jInput] Error!! Button component is Not Found!!");
        }
    }
        public override void Reset()
        {
            gameObject     = null;
            navigationMode = Navigation.Mode.Automatic;

            resetOnExit = false;
        }
Exemple #5
0
        public PanelConfig(string key,
                           string defaultSelectableKey,
                           PanelObjectConfig[] panelObjects,
                           GameObject[] supplementalObjects = null,
                           NavigationType navigation        = NavigationType.Vertical,
                           Action <List <Selectable> > navigationCallback = null,
                           GameObject prefabOverride = null,
                           Navigation.Mode mode      = UnityEngine.UI.Navigation.Mode.Explicit,
                           Action <PanelManager, List <Selectable> > panelNavigationCallback            = null,
                           Func <PanelManager, List <Selectable>, GameObject> defaultSelectableCallback = null,
                           Action <GameObject, PanelManager> creationCallback  = null,
                           Action <GameObject, PanelManager> onDisplayCallback = null)
        {
            Key = key;
            DefaultSelectableKey      = defaultSelectableKey;
            PanelObjects              = panelObjects;
            SupplementalObjects       = supplementalObjects;
            Navigation                = navigation;
            NavigationCallback        = navigationCallback;
            NavigationMode            = mode;
            PanelNavigationCallback   = panelNavigationCallback;
            DefaultSelectableCallback = defaultSelectableCallback;
            CreationCallback          = creationCallback;
            OnDisplayCallback         = onDisplayCallback;

            PrefabOverride = prefabOverride;
        }
Exemple #6
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            if (NavigationDrawer.s_Styles == null)
            {
                NavigationDrawer.s_Styles = new NavigationDrawer.Styles();
            }
            Rect position = pos;

            position.height = EditorGUIUtility.singleLineHeight;
            SerializedProperty serializedProperty = prop.FindPropertyRelative("m_Mode");

            Navigation.Mode navigationMode = NavigationDrawer.GetNavigationMode(serializedProperty);
            EditorGUI.PropertyField(position, serializedProperty, NavigationDrawer.s_Styles.navigationContent);
            EditorGUI.indentLevel++;
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            if (navigationMode == Navigation.Mode.Explicit)
            {
                SerializedProperty property  = prop.FindPropertyRelative("m_SelectOnUp");
                SerializedProperty property2 = prop.FindPropertyRelative("m_SelectOnDown");
                SerializedProperty property3 = prop.FindPropertyRelative("m_SelectOnLeft");
                SerializedProperty property4 = prop.FindPropertyRelative("m_SelectOnRight");
                EditorGUI.PropertyField(position, property);
                position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                EditorGUI.PropertyField(position, property2);
                position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                EditorGUI.PropertyField(position, property3);
                position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                EditorGUI.PropertyField(position, property4);
                position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            }
            EditorGUI.indentLevel--;
        }
        public static void SetNavigationMode(this Selectable selectable, Navigation.Mode mode)
        {
            Navigation navigation = selectable.navigation;

            navigation.mode       = mode;
            selectable.navigation = navigation;
        }
Exemple #8
0
    void BlockMoveDir()
    {
        PrevNavMode = ThisButton.navigation.mode;
        Navigation TempNav = ThisButton.navigation;

        TempNav.mode          = Navigation.Mode.None;
        ThisButton.navigation = TempNav;
    }
        public virtual T AddItem <T>(Navigation.Mode navigationMode, bool navigationInverse) where T : IComponent
        {
            if (this.source == null)
            {
                return(default(T));
            }

            var instance = this.GetInstance(this.Count());

            if (instance == null)
            {
                return(default(T));
            }

            if (this.scrollRect != null && this.scrollRect.content != null)
            {
                instance.SetParent(this.scrollRect.content, setTransformAsSource: false);
            }
            else if (this.content != null)
            {
                instance.SetParent(this.content.transform, setTransformAsSource: false);
            }

            if (instance != null && instance.transform.localPosition.z != 0f)
            {
                var pos = instance.transform.localPosition;
                pos.z = 0f;
                instance.transform.localPosition = pos;
            }

            if (instance != null && instance.transform.localScale.x != 1f)
            {
                instance.transform.localScale = Vector3.one;
            }

            if (instance is LinkerComponent && typeof(T) != typeof(LinkerComponent))
            {
                //instance.OnInit();
                instance.gameObject.SetActive(true);
                var linkerComponent = (instance as LinkerComponent).Get <WindowComponent>();
                if (linkerComponent != null)
                {
                    instance = linkerComponent;
                }
            }

            if (instance != null)
            {
                instance.gameObject.SetActive(true);
            }

            this.Refresh();

            this.OnNewItem(instance);

            return((T)(instance as IComponent));
        }
Exemple #10
0
    /// <summary>
    /// 设置导航模式
    /// </summary>
    /// <param name="mySelectable"></param>
    /// <param name="mode"></param>
    public static void SetNavigationMode(MySelectable mySelectable, Navigation.Mode mode)
    {
        if (!mySelectable)
        {
            return;
        }
        var navigation = mySelectable.navigation;

        navigation.mode         = mode;
        mySelectable.navigation = navigation;
    }
        protected override void ReadFromImpl(object obj)
        {
            base.ReadFromImpl(obj);
            Navigation uo = (Navigation)obj;

            mode          = uo.mode;
            selectOnUp    = ToID(uo.selectOnUp);
            selectOnDown  = ToID(uo.selectOnDown);
            selectOnLeft  = ToID(uo.selectOnLeft);
            selectOnRight = ToID(uo.selectOnRight);
        }
        public IButtonComponent SetNavigationMode(Navigation.Mode mode)
        {
            if (this.button != null)
            {
                var nav = this.button.navigation;
                nav.mode = mode;
                this.button.navigation = nav;
            }

            return(this);
        }
Exemple #13
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            Rect drawRect = pos;

            drawRect.height = EditorGUIUtility.singleLineHeight;

            SerializedProperty navigation = prop.FindPropertyRelative("m_Mode");
            SerializedProperty wrapAround = prop.FindPropertyRelative("m_WrapAround");

            Navigation.Mode navMode = GetNavigationMode(navigation);

            EditorGUI.PropertyField(drawRect, navigation, s_Styles.navigationContent);

            ++EditorGUI.indentLevel;

            drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;

            switch (navMode)
            {
            case Navigation.Mode.Horizontal:
            case Navigation.Mode.Vertical:
            {
                EditorGUI.PropertyField(drawRect, wrapAround);
                drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            }
            break;

            case Navigation.Mode.Explicit:
            {
                SerializedProperty selectOnUp    = prop.FindPropertyRelative("m_SelectOnUp");
                SerializedProperty selectOnDown  = prop.FindPropertyRelative("m_SelectOnDown");
                SerializedProperty selectOnLeft  = prop.FindPropertyRelative("m_SelectOnLeft");
                SerializedProperty selectOnRight = prop.FindPropertyRelative("m_SelectOnRight");

                EditorGUI.PropertyField(drawRect, selectOnUp);
                drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                EditorGUI.PropertyField(drawRect, selectOnDown);
                drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                EditorGUI.PropertyField(drawRect, selectOnLeft);
                drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                EditorGUI.PropertyField(drawRect, selectOnRight);
                drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            }
            break;
            }

            --EditorGUI.indentLevel;
        }
Exemple #14
0
    /// <summary>
    /// 显示网络加载界面
    /// </summary>
    public override void Show()
    {
        base.Show();

        _tempObj = UIController.instance.CurrentSelectedObj;
        if (!_tempObj)
        {
            return;
        }

        //_navigation = _tempObj.GetComponent<Selectable>().navigation;
        //_navigationMode = _navigation.mode;

        _navigationMode = _tempObj.GetComponent <Selectable>().navigation.mode;

        Util.SetNavigationMode(_tempObj.GetComponent <MySelectable>(), Navigation.Mode.None);
    }
        public override void OnEnter()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (UpdateCache(go))
            {
                selectable = cachedComponent;
            }

            if (selectable != null && resetOnExit.Value)
            {
                originalValue = selectable.navigation.mode;
            }

            DoSetValue();

            Finish();
        }
Exemple #16
0
 /// <summary>
 /// Selectables will navigate using Unity's automatic navigation mode. This is not recommended, as it tends to give unnatural results.
 /// </summary>
 public Builder SetAutomaticUnityNavigation(Navigation.Mode mode)
 {
     _navigation     = NavigationType.AutomaticUnity;
     _navigationMode = mode;
     return(this);
 }
Exemple #17
0
        /// <summary>
        /// Toggles the list.
        /// </summary>
        /// <param name="state">If set to <c>true</c> state.</param>
        protected virtual void ToggleList(bool state)
        {
            if (!this.IsActive())
            {
                return;
            }

            // Check if the list is not yet created
            if (this.m_ListObject == null)
            {
                this.CreateList();
            }

            // Make sure the creating of the list was successful
            if (this.m_ListObject == null)
            {
                return;
            }

            // Make sure we have the canvas group
            if (this.m_ListCanvasGroup != null)
            {
                // Disable or enable list interaction
                this.m_ListCanvasGroup.blocksRaycasts = state;
            }

            // Make sure navigation is enabled in open state
            if (state)
            {
                this.m_LastNavigationMode     = this.navigation.mode;
                this.m_LastSelectedGameObject = EventSystem.current.currentSelectedGameObject;

                Navigation newNav = this.navigation;
                newNav.mode     = Navigation.Mode.Vertical;
                this.navigation = newNav;

                // Set the select field as selected
                EventSystem.current.SetSelectedGameObject(this.gameObject);
            }
            else
            {
                Navigation newNav = this.navigation;
                newNav.mode     = this.m_LastNavigationMode;
                this.navigation = newNav;

                if (this.m_LastSelectedGameObject != null)
                {
                    EventSystem.current.SetSelectedGameObject(this.m_LastSelectedGameObject);
                }
            }

            // Bring to front
            if (state)
            {
                UIUtility.BringToFront(this.m_ListObject);
            }

            // Start the opening/closing animation
            if (this.listAnimationType == ListAnimationType.None || this.listAnimationType == ListAnimationType.Fade)
            {
                float targetAlpha = (state ? 1f : 0f);

                // Fade In / Out
                this.TweenListAlpha(targetAlpha, ((this.listAnimationType == ListAnimationType.Fade) ? this.listAnimationDuration : 0f), true);
            }
            else if (this.listAnimationType == ListAnimationType.Animation)
            {
                this.TriggerListAnimation(state ? this.listAnimationOpenTrigger : this.listAnimationCloseTrigger);
            }
        }
Exemple #18
0
        public virtual T AddItem <T>(Navigation.Mode navigationMode, bool navigationInverse) where T : IComponent
        {
            if (this.source == null)
            {
                return(default(T));
            }

            var instance = this.GetInstance(this.Count());

            if (instance == null)
            {
                return(default(T));
            }

            if (this.scrollRect != null && this.scrollRect.content != null)
            {
                instance.SetParent(this.scrollRect.content, setTransformAsSource: false);
            }
            else if (this.content != null)
            {
                instance.SetParent(this.content.transform, setTransformAsSource: false);
            }

            if (instance is LinkerComponent)
            {
                //instance.OnInit();
                instance.gameObject.SetActive(true);
                instance = (instance as LinkerComponent).Get <WindowComponent>();
            }

            if (instance != null)
            {
                instance.gameObject.SetActive(true);
            }

            #region Navigation
            if (this.lastSelectableInstance != instance)
            {
                if (navigationMode != Navigation.Mode.None)
                {
                    var selectableComp = instance as IButtonComponent;
                    if (selectableComp != null)
                    {
                        var selectable = selectableComp.GetSelectable();
                        if (selectable != null)
                        {
                            var nav = selectable.navigation;

                            if (navigationMode == Navigation.Mode.Automatic)
                            {
                                nav.mode = Navigation.Mode.Automatic;

                                selectable.navigation = nav;
                            }
                            else
                            {
                                nav.mode = Navigation.Mode.Explicit;

                                if (navigationMode == Navigation.Mode.Vertical ||
                                    navigationMode == Navigation.Mode.Horizontal)
                                {
                                    var prevSelectableComp = this.lastSelectableInstance;
                                    if (prevSelectableComp != null)
                                    {
                                        var prevSelectable = prevSelectableComp.GetSelectable();
                                        if (prevSelectable != null)
                                        {
                                            nav               = new Navigation();
                                            nav.mode          = Navigation.Mode.Explicit;
                                            nav.selectOnDown  = selectable.navigation.selectOnDown;
                                            nav.selectOnLeft  = selectable.navigation.selectOnLeft;
                                            nav.selectOnRight = selectable.navigation.selectOnRight;
                                            nav.selectOnUp    = selectable.navigation.selectOnUp;

                                            if (navigationInverse == false)
                                            {
                                                if (navigationMode == Navigation.Mode.Horizontal)
                                                {
                                                    nav.selectOnLeft = prevSelectable;
                                                }
                                                else
                                                {
                                                    nav.selectOnDown = prevSelectable;
                                                }
                                            }
                                            else
                                            {
                                                if (navigationMode == Navigation.Mode.Horizontal)
                                                {
                                                    nav.selectOnRight = prevSelectable;
                                                }
                                                else
                                                {
                                                    nav.selectOnUp = prevSelectable;
                                                }
                                            }
                                            selectable.navigation = nav;

                                            nav               = new Navigation();
                                            nav.mode          = Navigation.Mode.Explicit;
                                            nav.selectOnDown  = prevSelectable.navigation.selectOnDown;
                                            nav.selectOnLeft  = prevSelectable.navigation.selectOnLeft;
                                            nav.selectOnRight = prevSelectable.navigation.selectOnRight;
                                            nav.selectOnUp    = prevSelectable.navigation.selectOnUp;

                                            if (navigationInverse == false)
                                            {
                                                if (navigationMode == Navigation.Mode.Horizontal)
                                                {
                                                    nav.selectOnRight = selectable;
                                                }
                                                else
                                                {
                                                    nav.selectOnUp = selectable;
                                                }
                                            }
                                            else
                                            {
                                                if (navigationMode == Navigation.Mode.Horizontal)
                                                {
                                                    nav.selectOnLeft = selectable;
                                                }
                                                else
                                                {
                                                    nav.selectOnDown = selectable;
                                                }
                                            }
                                            prevSelectable.navigation = nav;
                                        } // Last selectable found
                                    }     // Last component not null
                                }         // Vertical or Horizontal
                            }             // Mode not Auto
                        }                 // Selectable found
                    }                     // Component not null

                    this.lastSelectableInstance = selectableComp;
                }                 // Navigation not None
            }
            #endregion

            this.Refresh();

            this.OnNewItem(instance);

            return((T)(instance as IComponent));
        }
    public override void OnInspectorGUI()
    {
        btn = (AnimatedButton)target;

        btn.interactable = EditorGUILayout.Toggle("Interactable", btn.interactable);
        btn.transition   = (Selectable.Transition)EditorGUILayout.Popup("Transition", (int)btn.transition,
                                                                        new string[] {
            Selectable.Transition.None.ToString(),
            Selectable.Transition.ColorTint.ToString(),
            Selectable.Transition.SpriteSwap.ToString(),
            Selectable.Transition.Animation.ToString()
        });

        //Display appropriate Transition Information
        EditorGUI.indentLevel++;
        if (btn.transition == Selectable.Transition.Animation)
        {
            btn.shouldColorTintForAnimation = EditorGUILayout.Toggle("Animate Color", btn.shouldColorTintForAnimation);
        }
        if (btn.transition == Selectable.Transition.ColorTint ||
            btn.transition == Selectable.Transition.SpriteSwap ||
            (btn.transition == Selectable.Transition.Animation && btn.shouldColorTintForAnimation))
        {
            btn.targetGraphic = (Image)EditorGUILayout.ObjectField("Target Graphic", btn.targetGraphic, typeof(Image), false);
        }
        if (btn.transition == Selectable.Transition.ColorTint ||
            (btn.transition == Selectable.Transition.Animation && btn.shouldColorTintForAnimation))
        {
            ColorBlock colorBlock = new ColorBlock();
            colorBlock.normalColor      = EditorGUILayout.ColorField("Normal Color", btn.colors.normalColor);
            colorBlock.highlightedColor = EditorGUILayout.ColorField("Highlighted Color", btn.colors.highlightedColor);
            colorBlock.pressedColor     = EditorGUILayout.ColorField("Pressed Color", btn.colors.pressedColor);
            colorBlock.disabledColor    = EditorGUILayout.ColorField("Disabled Color", btn.colors.disabledColor);
            colorBlock.colorMultiplier  = EditorGUILayout.Slider("Color Multiplier", btn.colors.colorMultiplier, 1f, 5f);
            colorBlock.fadeDuration     = EditorGUILayout.DelayedFloatField("Fade Duration", btn.colors.fadeDuration);
            btn.colors = colorBlock;
        }
        if (btn.transition == Selectable.Transition.SpriteSwap)
        {
            SpriteState spriteState = new SpriteState();
            spriteState.highlightedSprite = (Sprite)EditorGUILayout.ObjectField("Highlighted Sprite", btn.spriteState.highlightedSprite, typeof(Sprite), false, GUILayout.Height(16));
            spriteState.pressedSprite     = (Sprite)EditorGUILayout.ObjectField("Pressed Sprite", btn.spriteState.pressedSprite, typeof(Sprite), false, GUILayout.Height(16));
            spriteState.disabledSprite    = (Sprite)EditorGUILayout.ObjectField("Disabled Sprite", btn.spriteState.disabledSprite, typeof(Sprite), false, GUILayout.Height(16));
            btn.spriteState = spriteState;
        }
        if (btn.transition == Selectable.Transition.Animation)
        {
            btn.animationTriggers.normalTrigger      = EditorGUILayout.TextField("Normal Trigger", btn.animationTriggers.normalTrigger);
            btn.animationTriggers.highlightedTrigger = EditorGUILayout.TextField("Highlighted Trigger", btn.animationTriggers.highlightedTrigger);
            btn.animationTriggers.pressedTrigger     = EditorGUILayout.TextField("Pressed Trigger", btn.animationTriggers.pressedTrigger);
            btn.animationTriggers.disabledTrigger    = EditorGUILayout.TextField("Disabled Trigger", btn.animationTriggers.disabledTrigger);
        }
        EditorGUI.indentLevel--;

        GUILayout.Space(8);

        //Navigation Workaround
        Navigation.Mode mode = (Navigation.Mode)EditorGUILayout.Popup("Navigation", (int)btn.navigation.mode,
                                                                      new string[] {
            Navigation.Mode.None.ToString(),
            Navigation.Mode.Horizontal.ToString(),
            Navigation.Mode.Vertical.ToString(),
            Navigation.Mode.Automatic.ToString(),
            Navigation.Mode.Explicit.ToString()
        });
        Navigation nav = new Navigation();

        nav.mode       = mode;
        btn.navigation = nav;


        //UnityEvent
        serializedObject.Update();
        SerializedProperty onClick = serializedObject.FindProperty("clickEvent");

        EditorGUILayout.PropertyField(onClick);

        if (GUI.changed)
        {
            serializedObject.ApplyModifiedProperties();
        }
    }