diff options
Diffstat (limited to 'Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Navigation.cs')
-rw-r--r-- | Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Navigation.cs | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Navigation.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Navigation.cs new file mode 100644 index 0000000..98e77f9 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/Navigation.cs @@ -0,0 +1,74 @@ +using System; +using UnityEngine.Serialization; + +namespace UnityEngine.UI +{ + [Serializable] + public struct Navigation : IEquatable<Navigation> + { + /* + * This looks like it's not flags, but it is flags, + * the reason is that Automatic is considered horizontal + * and verical mode combined + */ + [Flags] + public enum Mode + { + None = 0, // 0 No navigation + Horizontal = 1, // 1 Automatic horizontal navigation + Vertical = 2, // 10 Automatic vertical navigation + Automatic = 3, // 11 Automatic navigation in both dimensions + Explicit = 4, // Explicitly specified only + } + + // Which method of navigation will be used. + [FormerlySerializedAs("mode")] + [SerializeField] + private Mode m_Mode; + + // Game object selected when the joystick moves up. Used when navigation is set to "Explicit". + [FormerlySerializedAs("selectOnUp")] + [SerializeField] + private Selectable m_SelectOnUp; + + // Game object selected when the joystick moves down. Used when navigation is set to "Explicit". + [FormerlySerializedAs("selectOnDown")] + [SerializeField] + private Selectable m_SelectOnDown; + + // Game object selected when the joystick moves left. Used when navigation is set to "Explicit". + [FormerlySerializedAs("selectOnLeft")] + [SerializeField] + private Selectable m_SelectOnLeft; + + // Game object selected when the joystick moves right. Used when navigation is set to "Explicit". + [FormerlySerializedAs("selectOnRight")] + [SerializeField] + private Selectable m_SelectOnRight; + + public Mode mode { get { return m_Mode; } set { m_Mode = value; } } + public Selectable selectOnUp { get { return m_SelectOnUp; } set { m_SelectOnUp = value; } } + public Selectable selectOnDown { get { return m_SelectOnDown; } set { m_SelectOnDown = value; } } + public Selectable selectOnLeft { get { return m_SelectOnLeft; } set { m_SelectOnLeft = value; } } + public Selectable selectOnRight { get { return m_SelectOnRight; } set { m_SelectOnRight = value; } } + + static public Navigation defaultNavigation + { + get + { + var defaultNav = new Navigation(); + defaultNav.m_Mode = Mode.Automatic; + return defaultNav; + } + } + + public bool Equals(Navigation other) + { + return mode == other.mode && + selectOnUp == other.selectOnUp && + selectOnDown == other.selectOnDown && + selectOnLeft == other.selectOnLeft && + selectOnRight == other.selectOnRight; + } + } +} |