Adventure Creator  1.66.8
An adventure game toolkit for Unity, by Chris Burton, ICEBOX Studios 2013-2018
AC.PlayerMenus Class Reference
Inheritance diagram for AC.PlayerMenus:

Public Member Functions

void OnStart ()
 
void RebuildMenus (MenuManager menuManager=null)
 Rebuilds the game's Menus, either from the existing MenuManager asset, or from a new one. More...
 
void AfterLoad ()
 
void AfterSceneAdd ()
 
void ClearParents ()
 
void DrawLoadingMenus ()
 
void DrawMenus ()
 
Menu GetMenuWithElement (MenuElement _element)
 Gets the Menu that a given MenuElement is a part of More...
 
void DrawMenu (AC.Menu menu, int languageNumber=0)
 Draws an Adventure Creator-sourced Menu. This should be called from OnGUI() More...
 
void UpdateMenuPosition (AC.Menu menu, Vector2 invertedMouse, bool force=false)
 Updates a Menu's position. More...
 
void UpdateMenu (AC.Menu menu, int languageNumber=0, bool justPosition=false, bool updateElements=true)
 Updates a Menu's display and position More...
 
bool IsEventSystemSelectingObject (GameObject _gameObject)
 Checks if the Unity UI EventSystem currently has a given GameObject selected. More...
 
bool IsEventSystemSelectingObject ()
 Checks if the Unity UI EventSystem currently has any GameObject selected. More...
 
bool DeselectEventSystemMenu (Menu _menu)
 De-selects the Unity UI EventSystem's selected gameobject if it is associated with a given Menu. More...
 
void RefreshDialogueOptions ()
 
void UpdateLoadingMenus ()
 
void CheckForInput ()
 
void UpdateAllMenus ()
 
void CheckCrossfade (AC.Menu _menu)
 Begins fading in the second Menu in a crossfade if the first Menu matches the supplied parameter. More...
 
void SelectInputBox (MenuInput input)
 Selects a MenuInput element, allowing the player to enter text into it. More...
 
void OnTurnOffMenu (Menu menu)
 Called automatically whenever a Menu is turned off More...
 
void DeselectInputBox (MenuElement menuElement)
 Deselects the active InputBox element if it is the one in the parameter More...
 
void OpenDocumentMenus ()
 Turns on all Menus with an appearType of OnViewDocument
 
void RemoveSpeechFromMenu (Speech speech)
 Unassigns a Speech line from any temporarily-duplicated Menus. This will signal such Menus that they can be removed. More...
 
void AssignSpeechToMenu (Speech speech)
 Duplicates any Menu set to display a single speech line. More...
 
Menu [] GetMenusAssignedToSpeech (Speech speech)
 Gets all Menus associated with a given Speech line More...
 
void CrossFade (AC.Menu _menuTo)
 Crossfades to a Menu. Any other Menus will be turned off. More...
 
void CloseInteractionMenus ()
 Closes all "Interaction" Menus.
 
void EnableInteractionMenus (Hotspot hotspotFor)
 Shows any Menus with appearType = AppearType.OnInteraction, and connected to a given Hotspot. More...
 
void EnableInteractionMenus (InvItem itemFor)
 Shows any Menus with appearType = AppearType.OnInteraction, and connected to a given Inventory item to. More...
 
void DisableHotspotMenus ()
 
string GetHotspotLabel ()
 Gets the complete Hotspot label to be displayed in a MenuLabel element with labelType = AC_LabelType.Hotspot. More...
 
bool ArePauseMenusOn (Menu excludingMenu=null)
 Checks if any Menus that pause the game are currently turned on. More...
 
void ForceOffSubtitles (SpeechMenuLimit speechMenuLimit=SpeechMenuLimit.All)
 Instantly turns off all Menus that have appearType = AppearType.WhenSpeechPlays. More...
 
Menu GetMenuWithCanvas (Canvas canvas)
 Gets the Menu associated with a given Unity UI Canvas</summar>

Parameters
canvasThe Canvas object linked to the Menu to be found
Returns
The Menu associated with a given Unity UI Canvas

 
void RegisterCustomMenu (Menu menu, bool deleteWhenTurnOff=false)
 Registers a script-created Menu instance, so that it's click-handling, updating and rendering are handled automatically. More...
 
void UnregisterCustomMenu (Menu menu, bool showError=true)
 Unregisters a script-created Menu instance, so that it is no longer updated automatically. More...
 
Menu [] GetRegisteredCustomMenus ()
 Gets all Menu instances currently registered as custom Menus that are automatically updated by PlayerMenus More...
 
void DestroyCustomMenus ()
 Destroys and unregisters all custom Menus registered with PlayerMenus
 
void RecalculateAll ()
 
void FindFirstSelectedElement (Menu menuToIgnore=null)
 Selects the first element GameObject in a Unity UI-based Menu. More...
 
void SelectUIElement (GameObject objectToSelect)
 Selects a Unity UI GameObject More...
 
int GetElementOverCursorID ()
 Gets the ID number of the CursorIcon, defined in CursorManager, to switch to based on what MenuElement the cursor is currently over More...
 
void SetManualSaveLock (bool state)
 Sets the state of the manual save lock. More...
 
bool IsMouseOverMenu ()
 Checks if the cursor is hovering over a Menu. More...
 
bool IsMouseOverInventory ()
 Checks if the cursor is hovering over an Inventory
 
bool IsMouseOverInteractionMenu ()
 Checks if the cursor is hovering over a Menu with appearType = AppearType.OnInteraction. More...
 
bool IsInteractionMenuOn ()
 Checks if any Menu with appearType = AppearType.OnInteraction is on. More...
 
bool IsCyclingInteractionMenu ()
 Checks if the player is currently manipulating an Interaction Menu by cycling the Interaction elements inside it. More...
 
bool IsPausingInteractionMenuOn ()
 Checks if the last-opened Menu with appearType = AppearType.OnInteraction is both open and set to pause the game. More...
 
void MakeUIInteractive ()
 
void MakeUINonInteractive ()
 
MainData SaveMainData (MainData mainData)
 Updates a MainData class with its own variables that need saving. More...
 
void LoadMainData (MainData mainData)
 Updates its own variables from a MainData class. More...
 
void PreScreenshotBackup ()
 
void PostScreenshotBackup ()
 

Static Public Member Functions

static List< MenuGetMenus (bool includeDuplicatesAndCustom=false)
 Gets a List of all defined Menus. More...
 
static Menu GetMenuWithName (string menuName)
 Gets a Menu with a specific name. More...
 
static MenuElement GetElementWithName (string menuName, string menuElementName)
 Gets a MenuElement with a specific name. More...
 
static bool IsSavingLocked (Action _actionToIgnore=null)
 Checks if saving cannot be performed at this time. More...
 
static void ResetInventoryBoxes ()
 
static void CreateRecipe ()
 
static void ForceOffAllMenus (bool onlyPausing=false)
 Instantly turns off all Menus. More...
 
static void SimulateClick (string menuName, string menuElementName, int slot=1)
 Simulates the clicking of a MenuElement. More...
 
static void SimulateClick (string menuName, MenuElement _element, int _slot=1)
 Simulates the clicking of a MenuElement. More...
 

Properties

UnityEngine.EventSystems.EventSystem EventSystem [get]
 

Detailed Description

This script handles the initialisation, position and display of all Menus defined in MenuManager. Menus are transferred from MenuManager to a local List within this script when the game begins. It must be placed on the PersistentEngine prefab.

Member Function Documentation

◆ AfterLoad()

void AC.PlayerMenus.AfterLoad ( )

Initialises the menu system after a scene change. This is called manually by SaveSystem so that the order is correct.

◆ ArePauseMenusOn()

bool AC.PlayerMenus.ArePauseMenusOn ( Menu  excludingMenu = null)

Checks if any Menus that pause the game are currently turned on.

Parameters
excludingMenuIf assigned, this Menu will be excluded from the check
Returns
True if any Menus that pause the game are currently turned on

◆ AssignSpeechToMenu()

void AC.PlayerMenus.AssignSpeechToMenu ( Speech  speech)

Duplicates any Menu set to display a single speech line.

Parameters
speechThe Speech line to assign to any duplicated Menu

◆ CheckCrossfade()

void AC.PlayerMenus.CheckCrossfade ( AC.Menu  _menu)

Begins fading in the second Menu in a crossfade if the first Menu matches the supplied parameter.

Parameters
_menuThe Menu to check for. If this menu is crossfading out, then it will be turned off, and the second Menu will fade in

◆ CheckForInput()

void AC.PlayerMenus.CheckForInput ( )

Checks for inputs made to all Menus. This is called every frame by StateHandler.

◆ ClearParents()

void AC.PlayerMenus.ClearParents ( )

Clears the parents of any Unity UI-based Menu Canvases. This makes them able to survive a scene change.

◆ CreateRecipe()

static void AC.PlayerMenus.CreateRecipe ( )
static

Takes the ingredients supplied to a MenuCrafting element and sets the appropriate outcome of another MenuCrafting element with craftingType = CraftingElementType.Output.

◆ CrossFade()

void AC.PlayerMenus.CrossFade ( AC.Menu  _menuTo)

Crossfades to a Menu. Any other Menus will be turned off.

Parameters
_menuToThe Menu to crossfade to

◆ DeselectEventSystemMenu()

bool AC.PlayerMenus.DeselectEventSystemMenu ( Menu  _menu)

De-selects the Unity UI EventSystem's selected gameobject if it is associated with a given Menu.

Parameters
_menuThe Menu to deselect
Returns
True if the Unity UI EventSystem's selected gameobject was in the given Menu

◆ DeselectInputBox()

void AC.PlayerMenus.DeselectInputBox ( MenuElement  menuElement)

Deselects the active InputBox element if it is the one in the parameter

Parameters
menuElementThe InputBox element that should be disabled

◆ DisableHotspotMenus()

void AC.PlayerMenus.DisableHotspotMenus ( )

Turns off any Menus with appearType = AppearType.OnHotspot.

◆ DrawLoadingMenus()

void AC.PlayerMenus.DrawLoadingMenus ( )

Draws any OnGUI-based Menus set to appear while the game is loading.

◆ DrawMenu()

void AC.PlayerMenus.DrawMenu ( AC.Menu  menu,
int  languageNumber = 0 
)

Draws an Adventure Creator-sourced Menu. This should be called from OnGUI()

Parameters
menuThe Menu to draw
languageNumberThe index number of the language to use (0 = default)

◆ DrawMenus()

void AC.PlayerMenus.DrawMenus ( )

Draws all OnGUI-based Menus.

◆ EnableInteractionMenus() [1/2]

void AC.PlayerMenus.EnableInteractionMenus ( Hotspot  hotspotFor)

Shows any Menus with appearType = AppearType.OnInteraction, and connected to a given Hotspot.

Parameters
_hotspotForThe Hotspot to connect the Menus to.

◆ EnableInteractionMenus() [2/2]

void AC.PlayerMenus.EnableInteractionMenus ( InvItem  itemFor)

Shows any Menus with appearType = AppearType.OnInteraction, and connected to a given Inventory item to.

Parameters
_itemForThe Inventory item to connect the Menus to.

◆ FindFirstSelectedElement()

void AC.PlayerMenus.FindFirstSelectedElement ( Menu  menuToIgnore = null)

Selects the first element GameObject in a Unity UI-based Menu.

Parameters
menuToIgnoreIf set, this menu will be ignored when searching

◆ ForceOffAllMenus()

static void AC.PlayerMenus.ForceOffAllMenus ( bool  onlyPausing = false)
static

Instantly turns off all Menus.

Parameters
onlyPausingIf True, then only Menus with pauseWhenEnabled = True will be turned off

◆ ForceOffSubtitles()

void AC.PlayerMenus.ForceOffSubtitles ( SpeechMenuLimit  speechMenuLimit = SpeechMenuLimit.All)

Instantly turns off all Menus that have appearType = AppearType.WhenSpeechPlays.

Parameters
speechMenuLimitThe type of speech to kill (All, BlockingOnly, BackgroundOnly)

◆ GetElementOverCursorID()

int AC.PlayerMenus.GetElementOverCursorID ( )

Gets the ID number of the CursorIcon, defined in CursorManager, to switch to based on what MenuElement the cursor is currently over

Returns
The ID number of the CursorIcon, defined in CursorManager, to switch to based on what MenuElement the cursor is currently over

◆ GetElementWithName()

static MenuElement AC.PlayerMenus.GetElementWithName ( string  menuName,
string  menuElementName 
)
static

Gets a MenuElement with a specific name.

Parameters
menuNameThe name (title) of the Menu to find
menuElementNameThe name (title) of the MenuElement with the Menu to find
Returns
The MenuElement with the specific name

◆ GetHotspotLabel()

string AC.PlayerMenus.GetHotspotLabel ( )

Gets the complete Hotspot label to be displayed in a MenuLabel element with labelType = AC_LabelType.Hotspot.

Returns
The complete Hotspot label to be displayed in a MenuLabel element with labelType = AC_LabelType.Hotspot

◆ GetMenus()

static List<Menu> AC.PlayerMenus.GetMenus ( bool  includeDuplicatesAndCustom = false)
static

Gets a List of all defined Menus.

Parameters
includeDuplicatesAndCustomIf True, then duplicate and custom Menus will also be included in the returned List
Returns
A List of all defined Menus

◆ GetMenusAssignedToSpeech()

Menu [] AC.PlayerMenus.GetMenusAssignedToSpeech ( Speech  speech)

Gets all Menus associated with a given Speech line

Parameters
speechThe Speech line in question
Returns
An array of all Menus associated with the Speech line

◆ GetMenuWithElement()

Menu AC.PlayerMenus.GetMenuWithElement ( MenuElement  _element)

Gets the Menu that a given MenuElement is a part of

Parameters
_elementThe MenuElement to get the Menu for
Returns
The Menu that the MenuElement is a part of

◆ GetMenuWithName()

static Menu AC.PlayerMenus.GetMenuWithName ( string  menuName)
static

Gets a Menu with a specific name.

Parameters
menuNameThe name (title) of the Menu to find
Returns
The Menu with the specific name

◆ GetRegisteredCustomMenus()

Menu [] AC.PlayerMenus.GetRegisteredCustomMenus ( )

Gets all Menu instances currently registered as custom Menus that are automatically updated by PlayerMenus

Returns
An array of all Menu instances currently registered as custom Menus that are automatically updated by PlayerMenus

◆ IsCyclingInteractionMenu()

bool AC.PlayerMenus.IsCyclingInteractionMenu ( )

Checks if the player is currently manipulating an Interaction Menu by cycling the Interaction elements inside it.

Returns
True if the player is currently manipulating an Interaction Menu by cycling the Interaction elements inside it.

◆ IsEventSystemSelectingObject() [1/2]

bool AC.PlayerMenus.IsEventSystemSelectingObject ( GameObject  _gameObject)

Checks if the Unity UI EventSystem currently has a given GameObject selected.

Parameters
_gameObjectThe GameObject to check
Returns
True if the Unity UI EventSystem currently has a given GameObject selected

◆ IsEventSystemSelectingObject() [2/2]

bool AC.PlayerMenus.IsEventSystemSelectingObject ( )

Checks if the Unity UI EventSystem currently has any GameObject selected.

Returns
True if the Unity UI EventSystem currently has any GameObject selected

◆ IsInteractionMenuOn()

bool AC.PlayerMenus.IsInteractionMenuOn ( )

Checks if any Menu with appearType = AppearType.OnInteraction is on.

Returns
True if any Menu with appearType = AppearType.OnInteraction is on.

◆ IsMouseOverInteractionMenu()

bool AC.PlayerMenus.IsMouseOverInteractionMenu ( )

Checks if the cursor is hovering over a Menu with appearType = AppearType.OnInteraction.

Returns
True if the cursor is hovering over a Menu with appearType = AppearType.OnInteraction.

◆ IsMouseOverMenu()

bool AC.PlayerMenus.IsMouseOverMenu ( )

Checks if the cursor is hovering over a Menu.

Returns
True if the cursor is hovering over a Menu

◆ IsPausingInteractionMenuOn()

bool AC.PlayerMenus.IsPausingInteractionMenuOn ( )

Checks if the last-opened Menu with appearType = AppearType.OnInteraction is both open and set to pause the game.

Returns
True if the last-opened Menu with appearType = AppearType.OnInteraction is both open and set to pause the game.

◆ IsSavingLocked()

static bool AC.PlayerMenus.IsSavingLocked ( Action  _actionToIgnore = null)
static

Checks if saving cannot be performed at this time.

Any gameplay-blocking ActionList that contains this Action will be excluded from the check

Returns
True if saving cannot be performed at this time

◆ LoadMainData()

void AC.PlayerMenus.LoadMainData ( MainData  mainData)

Updates its own variables from a MainData class.

Parameters
mainDataThe MainData class to load from

◆ MakeUIInteractive()

void AC.PlayerMenus.MakeUIInteractive ( )

Makes all Menus linked to Unity UI interactive.

◆ MakeUINonInteractive()

void AC.PlayerMenus.MakeUINonInteractive ( )

Makes all Menus linked to Unity UI non-interactive.

◆ OnTurnOffMenu()

void AC.PlayerMenus.OnTurnOffMenu ( Menu  menu)

Called automatically whenever a Menu is turned off

Parameters
menuThe Menu that was turned off

◆ PostScreenshotBackup()

void AC.PlayerMenus.PostScreenshotBackup ( )

Restores the menu and cursor systems to their former states, after taking a screenshot.

◆ PreScreenshotBackup()

void AC.PlayerMenus.PreScreenshotBackup ( )

Backs up the state of the menu and cursor systems, and disables them, before taking a screenshot.

◆ RebuildMenus()

void AC.PlayerMenus.RebuildMenus ( MenuManager  menuManager = null)

Rebuilds the game's Menus, either from the existing MenuManager asset, or from a new one.

Parameters
menuManagerThe Menu Manager to use for Menu generation. If left empty, the default Menu Manager will be used.

◆ RecalculateAll()

void AC.PlayerMenus.RecalculateAll ( )

Recalculates the position, size and display of all Menus. This is an intensive process, and should not be called every fame.

◆ RefreshDialogueOptions()

void AC.PlayerMenus.RefreshDialogueOptions ( )

Refreshes any active MenuDialogList elements, after changing the state of dialogue options.

◆ RegisterCustomMenu()

void AC.PlayerMenus.RegisterCustomMenu ( Menu  menu,
bool  deleteWhenTurnOff = false 
)

Registers a script-created Menu instance, so that it's click-handling, updating and rendering are handled automatically.

Parameters
menuThe custom Menu to register
deleteWhenTurnOffWhen True, the associated UI canvas will be deleted (if present), and the menu will be unregistered, automatically when the Menu is turned off

◆ RemoveSpeechFromMenu()

void AC.PlayerMenus.RemoveSpeechFromMenu ( Speech  speech)

Unassigns a Speech line from any temporarily-duplicated Menus. This will signal such Menus that they can be removed.

Parameters
speechThe Speech line to unassign

◆ ResetInventoryBoxes()

static void AC.PlayerMenus.ResetInventoryBoxes ( )
static

Calls RecalculateSize() on all MenuInventoryBox elements.

◆ SaveMainData()

MainData AC.PlayerMenus.SaveMainData ( MainData  mainData)

Updates a MainData class with its own variables that need saving.

Parameters
mainDataThe original MainData class
Returns
The updated MainData class

◆ SelectInputBox()

void AC.PlayerMenus.SelectInputBox ( MenuInput  input)

Selects a MenuInput element, allowing the player to enter text into it.

Parameters
inputThe input box to select

◆ SelectUIElement()

void AC.PlayerMenus.SelectUIElement ( GameObject  objectToSelect)

Selects a Unity UI GameObject

Parameters
objectToSelectThe UI GameObject to select

◆ SetManualSaveLock()

void AC.PlayerMenus.SetManualSaveLock ( bool  state)

Sets the state of the manual save lock.

Parameters
stateIf True, then saving will be manually disabled

◆ SimulateClick() [1/2]

static void AC.PlayerMenus.SimulateClick ( string  menuName,
string  menuElementName,
int  slot = 1 
)
static

Simulates the clicking of a MenuElement.

Parameters
menuNameThe name (title) of the Menu that contains the MenuElement
menuElementNameThe name (title) of the MenuElement
slotThe index number of the slot, if the MenuElement has multiple slots

◆ SimulateClick() [2/2]

static void AC.PlayerMenus.SimulateClick ( string  menuName,
MenuElement  _element,
int  _slot = 1 
)
static

Simulates the clicking of a MenuElement.

Parameters
menuNameThe name (title) of the Menu that contains the MenuElement
_elementThe MenuElement
slotThe index number of the slot, if the MenuElement has multiple slots

◆ UnregisterCustomMenu()

void AC.PlayerMenus.UnregisterCustomMenu ( Menu  menu,
bool  showError = true 
)

Unregisters a script-created Menu instance, so that it is no longer updated automatically.

Parameters
menuThe custom Menu to unregister
showErrorIf True, then the Console will display a Warning message if the Menu is not registered

◆ UpdateAllMenus()

void AC.PlayerMenus.UpdateAllMenus ( )

Updates the state of all Menus. This is called every frame by StateHandler.

◆ UpdateLoadingMenus()

void AC.PlayerMenus.UpdateLoadingMenus ( )

Updates the state of all Menus set to appear while the game is loading.

◆ UpdateMenu()

void AC.PlayerMenus.UpdateMenu ( AC.Menu  menu,
int  languageNumber = 0,
bool  justPosition = false,
bool  updateElements = true 
)

Updates a Menu's display and position

Parameters
menuThe Menu to update
languageNumberThe index number of the language to use (0 = default)
justPositionIf True, then only the Menu's position will be updated - not its content
updateElementsIf True, then the Menu's elements will be updated as well

◆ UpdateMenuPosition()

void AC.PlayerMenus.UpdateMenuPosition ( AC.Menu  menu,
Vector2  invertedMouse,
bool  force = false 
)

Updates a Menu's position.

Parameters
menuThe Menu to reposition
invertedMouseThe y-inverted mouse position
forceIf True, the position will be updated regardless of whether or not the Menu is on.

Property Documentation

◆ EventSystem

UnityEngine.EventSystems.EventSystem AC.PlayerMenus.EventSystem
get

The EventSystem used by AC Menus.