BomberUnits
...a Unity learning project
MenuElement Class Reference

This behaviour enables a UI gameobject to be shown and hidden with an animation. More...

+ Inheritance diagram for MenuElement:
+ Collaboration diagram for MenuElement:

Public Member Functions

void Hide ()
 Moves the element out of view using the screen direction setting.
 
void HideUp ()
 Convenience function for direct callback, overwrites the set hide direction.
 
void HideDown ()
 Convenience function for direct callback, overwrites the set hide direction.
 
void HideLeft ()
 Convenience function for direct callback, overwrites the set hide direction.
 
void HideRight ()
 Convenience function for direct callback, overwrites the set hide direction.
 
void Hide (ScreenDir toDir)
 Hides the given element from view towards the given direction, but only if not already hidden.
 
void Show ()
 Moves the element into view using the screen direction setting.
 
void ShowUp ()
 Convenience function for direct callback, overwrites the set show direction.
 
void ShowDown ()
 Convenience function for direct callback, overwrites the set show direction.
 
void ShowLeft ()
 Convenience function for direct callback, overwrites the set show direction.
 
void ShowRight ()
 Convenience function for direct callback, overwrites the set show direction.
 
void Show (ScreenDir fromDir)
 Moves the given element into view from the given direction, but only if not already shown. More...
 

Static Public Member Functions

static void HideAllCurShown ()
 Hides all shown elements to their directions with their delays.
 

Public Attributes

GameObject container
 The optional parent (layout) container is de-/activated as well.
 
ScreenDir showDir = ScreenDir.Up
 The direction from which this element will appear.
 
ScreenDir hideDir = ScreenDir.Up
 The direction to which this element will disappear.
 
float showDelay = 0.26f
 [s] The delay for the Show animation start.
 
float hideDelay = 0.00f
 [s] The delay for the Hide animation start.
 

Static Public Attributes

static List< MenuElementcurShownElements = new List<MenuElement>()
 A List to store all currently shown MenuElements, used to be able to close all visible.
 

Private Member Functions

void Awake ()
 Awake is called before any Start calls and only once for each object. More...
 
bool isShown ()
 Gets the "visible" boolean parameter from the Animator.
 
IEnumerator ShowElementCo (ScreenDir fromDir)
 Coroutine allowing to delay the show animation as specified in the settings. More...
 
IEnumerator DisableAfterAnimFinishedCo (ScreenDir toDir)
 Coroutine waiting until the Closing animation is finished to disable the object hierarchy.
 

Private Attributes

Animator anim
 

Static Private Attributes

static string visibleBoolParamName = "isVisible"
 Animator Parameter name needed for modifying visibility.
 
static string directionIntParamName = "direction"
 Animator Parameter name needed for modifying the animation direction.
 
static Dictionary< ScreenDir, string > screenDirHiddenStateNames
 Dictionary of Animator State names for each animation direction. More...
 

Detailed Description

This behaviour enables a UI gameobject to be shown and hidden with an animation.

Definition at line 9 of file MenuElement.cs.

Member Function Documentation

◆ Awake()

void Awake ( )
inlineprivate

Awake is called before any Start calls and only once for each object.

Used to register a shown element if not already present.

Definition at line 55 of file MenuElement.cs.

◆ Show()

void Show ( ScreenDir  fromDir)
inline

Moves the given element into view from the given direction, but only if not already shown.

Uses a Coroutine to delay the actual showing by the amount set on the element.

Definition at line 136 of file MenuElement.cs.

◆ ShowElementCo()

IEnumerator ShowElementCo ( ScreenDir  fromDir)
inlineprivate

Coroutine allowing to delay the show animation as specified in the settings.

The element and optional parent container are activated and moved to the front.

Definition at line 160 of file MenuElement.cs.

Member Data Documentation

◆ screenDirHiddenStateNames

Dictionary<ScreenDir, string> screenDirHiddenStateNames
staticprivate
Initial value:
=
new Dictionary<ScreenDir, string>() { { ScreenDir.Up, "HiddenUp" }, { ScreenDir.Down, "HiddenDown" }, { ScreenDir.Left, "HiddenLeft" }, { ScreenDir.Right, "HiddenRight" }
}

Dictionary of Animator State names for each animation direction.

Definition at line 32 of file MenuElement.cs.


The documentation for this class was generated from the following file: