• Home
  • Documentation
  • Guides
  • FAQ
  • Get Essential UI Pack
Search Results for

    Show / Hide Table of Contents
    • LlamaSoftware.UI
      • ButtonClickSoundPlayer
      • Draggable
      • EUIPButton
      • EUIPButton.ButtonLabelStyle
      • EUIPSlider
      • EUIPSlider.DisplayFormat
      • InputFieldSliderValueDisplay
      • MenuController
      • MultiValueToggle
      • MultiValueToggleArrow
      • MultiValueToggleArrow.OnPointerUpCallback
      • Page
      • Popover
      • ProgressBar
      • ScrollViewZoomFixer
      • SliderValueDisplay
      • SliderValueSetter
      • Spinner
      • UIAnimationConstants
      • UIAnimationConstants.Direction
      • UIAnimationConstants.EntryMode
    • LlamaSoftware.UI.Tabs
      • TabbedPanel
      • TabbedPanel.ChangeTabEvent
      • TabbedPanelContent
      • TabbedPanelHeader
    • LlamaSoftware.UI.Utility
      • CornersUIGradient
      • RotatableLinearUIGradient
      • SimpleProgressBar
      • TextUpdatingProgressBar
      • UIGradientUtils
      • UIGradientUtils.Matrix2x3

    Class MenuController

    The Controller for all of your pages. Use only 1 per Canvas. All Page Management should be done via a single instance of MenuController.

    Inheritance
    System.Object
    UnityEngine.Object
    UnityEngine.Component
    UnityEngine.Behaviour
    UnityEngine.MonoBehaviour
    MenuController
    Namespace: LlamaSoftware.UI
    Assembly: LlamaSoftware.UI.dll
    Syntax
    [DefaultExecutionOrder(1)]
    [RequireComponent(typeof(Canvas), typeof(Animator), typeof(CanvasGroup))]
    [RequireComponent(typeof(AudioSource))]
    public class MenuController : MonoBehaviour

    Fields

    CanvasAnimator

    Declaration
    protected Animator CanvasAnimator
    Field Value
    Type Description
    UnityEngine.Animator

    CurrentSelectable

    Declaration
    protected Selectable CurrentSelectable
    Field Value
    Type Description
    UnityEngine.UI.Selectable

    CurrentSelectedObject

    Declaration
    protected GameObject CurrentSelectedObject
    Field Value
    Type Description
    UnityEngine.GameObject

    EnableEscapeToGoBack

    If enabled, will support pressing ESC key to pop pages, and fade out the Canvas (if CanvasGroup is attached) when all pages are popped

    Declaration
    public bool EnableEscapeToGoBack
    Field Value
    Type Description
    System.Boolean

    EnableTabSelection

    If enabled, will process Tab and Shift+Tab as navigation events similar to what you expect from an HTML page, or forms in general.

    Declaration
    public bool EnableTabSelection
    Field Value
    Type Description
    System.Boolean

    FadeOutCanvasWhenNoPagesRemaining

    If true, will make the Canvas fade out when all pages have been popped. Pressing Escape again will make the Canvas fade back in.

    Declaration
    public bool FadeOutCanvasWhenNoPagesRemaining
    Field Value
    Type Description
    System.Boolean

    FirstFocusItem

    The first GameObject you would like the current UnityEngine.EventSystems.EventSystem to select

    Declaration
    public GameObject FirstFocusItem
    Field Value
    Type Description
    UnityEngine.GameObject

    ForceKeepOnePage

    When enabled, will force the Menu Controller to retain 1 page in the stack at all times. This overrides the previous property FadeOutCanvasWhenNoPagesRemaining. This means if both are enabled, the Canvas will never fade out, and OnHide events will never be called.

    Declaration
    public bool ForceKeepOnePage
    Field Value
    Type Description
    System.Boolean

    InitialPage

    The Page to push on start.

    Declaration
    public Page InitialPage
    Field Value
    Type Description
    Page

    IsVisible

    Declaration
    protected bool IsVisible
    Field Value
    Type Description
    System.Boolean

    NextSelectable

    Declaration
    protected Selectable NextSelectable
    Field Value
    Type Description
    UnityEngine.UI.Selectable

    NO_PAGES_ON_STACK_WARNING

    Declaration
    protected const string NO_PAGES_ON_STACK_WARNING = "Trying to pop page when there are none on the stack!"
    Field Value
    Type Description
    System.String

    OnHide

    UnityEvent to call when the Canvas becomes inactive. Will be automatically called when FadeOutCanvasWhenNoPagesRemaining is enabled. Also called when FadeOut() is called.

    Declaration
    public UnityEvent OnHide
    Field Value
    Type Description
    UnityEngine.Events.UnityEvent

    OnShow

    UnityEvent to call when the Canvas becomes active. Will be invoked every time the Page Stack goes from 0 to 1 in size (including on Awake if InitialPage is set). Also called when FadeIn() is called.

    Declaration
    public UnityEvent OnShow
    Field Value
    Type Description
    UnityEngine.Events.UnityEvent

    PageStack

    Declaration
    protected Stack<Page> PageStack
    Field Value
    Type Description
    System.Collections.Generic.Stack<Page>

    RootCanvas

    Declaration
    protected Canvas RootCanvas
    Field Value
    Type Description
    UnityEngine.Canvas

    StartVisible

    Whether or not the Menu should be displayed by default on Start().

    Declaration
    [SerializeField]
    protected bool StartVisible
    Field Value
    Type Description
    System.Boolean

    Methods

    Awake()

    Declaration
    protected virtual void Awake()

    DisableSelectablesOnPage(Page)

    Disables all UnityEngine.UI.Selectable components that are children of the provided Page. Inverse of EnableSelectablesOnPage(Page).

    Declaration
    protected virtual void DisableSelectablesOnPage(Page page)
    Parameters
    Type Name Description
    Page page

    Page to disable children of

    EnableSelectablesOnPage(Page)

    Enables all UnityEngine.UI.Selectable components that are children of the provides Page. Inverwe of DisableSelectablesOnPage(Page).

    Declaration
    protected virtual void EnableSelectablesOnPage(Page page)
    Parameters
    Type Name Description
    Page page

    FadeIn()

    Fade in the root Canvas. Will call any UnityEvents bound to OnShow. Calls UIAnimationConstants on the connected Animator.

    Declaration
    public virtual void FadeIn()

    FadeOut()

    Fade out the root Canvas. Will call any UnityEvents bound to OnHide. Calls UIAnimationConstants on the connected Animator.

    Declaration
    public virtual void FadeOut()

    HandleTabSelect()

    Selects the next UnityEngine.UI.Selectable if the UnityEngine.KeyCode.Tab key is pressed, or the previous one if UnityEngine.KeyCode.LeftShift/UnityEngine.KeyCode.RightShift+UnityEngine.KeyCode.Tab is pressed.

    Declaration
    protected virtual void HandleTabSelect()

    IsPageInStack(Page)

    Returns if the provided Page is anywhere in the PageStack

    Declaration
    public bool IsPageInStack(Page page)
    Parameters
    Type Name Description
    Page page
    Returns
    Type Description
    System.Boolean

    IsPageOnTopOfStack(Page)

    Returns if the provided Page is at the top of the PageStack

    Declaration
    public bool IsPageOnTopOfStack(Page page)
    Parameters
    Type Name Description
    Page page
    Returns
    Type Description
    System.Boolean

    PopAllPages()

    Remove all Pages from the stack and fades out the Canvas

    Declaration
    public virtual void PopAllPages()

    PopPage()

    Remove the top Page from the stack and plays appropriate animations

    Declaration
    public virtual void PopPage()

    PushPage(Page)

    Add a new Page on top of the Page stack and plays appropriate animations.

    Declaration
    public virtual void PushPage(Page page)
    Parameters
    Type Name Description
    Page page

    The Page to add

    SelectFirstSelectable()

    Declaration
    protected virtual void SelectFirstSelectable()

    Start()

    Declaration
    protected virtual void Start()

    Update()

    Declaration
    protected virtual void Update()
    In This Article
    Back to top Generated by DocFX