Adventure Creator  1.79.1
An adventure game toolkit for Unity, by Chris Burton, ICEBOX Studios 2013-2022
AC.MenuLabel Class Reference
Inheritance diagram for AC.MenuLabel:
AC.MenuElement AC.ITranslatable

Public Member Functions

override void Declare ()
 
override MenuElement DuplicateSelf (bool fromEditor, bool ignoreUnityUI)
 Creates and returns a new MenuElement that has the same values as itself. More...
 
override void LoadUnityUI (AC.Menu _menu, Canvas canvas, bool addEventListeners=true)
 Initialises the linked Unity UI GameObject. More...
 
override RectTransform GetRectTransform (int _slot)
 Gets the boundary of the element, or a slot within it. More...
 
override void ShowGUI (Menu menu)
 
override bool CheckConvertGlobalVariableToLocal (int oldGlobalID, int newLocalID)
 Checks if the Element makes references from a given global variable to a given local variable More...
 
override int GetVariableReferences (int _varID)
 Gets the number of references the MenuElement makes to a global variable More...
 
override int UpdateVariableReferences (int oldVarID, int newVarID)
 Updates references the MenuElement makes to a global variable More...
 
override bool ReferencesObjectOrID (GameObject gameObject, int id)
 Checks if the Element makes reference to a particular GameObject More...
 
override int GetSlotIndex (GameObject gameObject)
 Gets the slot index that reference a particular GameObject More...
 
override void SetSpeech (Speech _speech)
 Assigns the element to a specific Speech line. More...
 
override void ClearSpeech ()
 
override void OnMenuTurnOn (Menu menu)
 Called whenever the Menu this is attached to is turned on. More...
 
override void PreDisplay (int _slot, int languageNumber, bool isActive)
 Performs all calculations necessary to display the element. More...
 
override void OverrideLabel (string newLabel, int _lineID=-1)
 
void UpdateLabelText (int languageNumber=0)
 
override void Display (GUIStyle _style, int _slot, float zoom, bool isActive)
 Draws the element using OnGUI. More...
 
override string GetLabel (int slot, int languageNumber)
 Gets the display text of the element, or a slot within it. More...
 
string GetTranslatableString (int index)
 Gets the text to be translated, given its index. More...
 
int GetTranslationID (int index)
 Gets the translation ID of a given text index. More...
 
void UpdateTranslatableString (int index, string updatedText)
 
int GetNumTranslatables ()
 Gets the maximum number of possible translatable texts. More...
 
bool HasExistingTranslation (int index)
 Checks if a given text index has already been assigned a unique translation ID. More...
 
void SetTranslationID (int index, int _lineID)
 Sets the translation ID of a given text index More...
 
string GetOwner (int index)
 Gets the name of the translatable text's owner. In the case of speech text, it is the name of the character. In the case of menu element text, it is the name of the menu element. More...
 
bool OwnerIsPlayer (int index)
 Checks if the translatable text's owner is a Player. This is necessary for speech lines, since multiple player prefabs can feasibly share the same line. More...
 
AC_TextType GetTranslationType (int index)
 Gets the translation type of a given text index. More...
 
bool CanTranslate (int index)
 Checks if a given text index can and should be translated. More...
 
- Public Member Functions inherited from AC.MenuElement
virtual void Copy (MenuElement _element)
 Copies the values of another MenuElement onto itself. More...
 
virtual void Initialise (AC.Menu _menu)
 Performs any initialisation that can only be done once the element has been instantiated at runtime. More...
 
virtual bool ProcessClick (AC.Menu _menu, int _slot, MouseState _mouseState)
 Performs what should happen when the element is clicked on. More...
 
virtual bool ProcessContinuousClick (AC.Menu _menu, MouseState _mouseState)
 Performs what should happen when the element is clicked on continuously. More...
 
virtual GameObject GetObjectToSelect (int slotIndex=0)
 Gets the linked Unity UI GameObject associated with this element. More...
 
void UpdateID (int[] idArray)
 Updates the ID number to something unique. More...
 
void UpdateLabel (int languageNumber)
 
virtual bool IsSelectedByEventSystem (int slotIndex)
 Checks if the element is selected by Unity UI's EventSystem (if the Menu is Unity UI-based). More...
 
virtual bool IsSelectableInteractable (int slotIndex)
 Checks if the element's linked Selectable is currently Interactable (if the Menu is Unity UI-based). More...
 
void ShowGUIStart (Menu menu)
 
virtual bool ReferencesAsset (ActionListAsset actionListAsset)
 Checks if the Menu makes reference to a particular ActionList asset More...
 
virtual void HideAllUISlots ()
 
virtual string GetHotspotLabelOverride (int _slot, int _language)
 Gets a string that overrides the default 'hotspot label'. More...
 
virtual void DrawOutline (bool isSelected, AC.Menu _menu)
 Draws an outline around the element. More...
 
Vector2[] GetSlotCentres (AC.Menu _menu)
 Gets the element's slot centres, as an array of Vector2s. This is used when keyboard-navigating menus More...
 
virtual void Shift (AC_ShiftInventory shiftType, int amount)
 Shifts which slots are on display, if the number of slots the element has exceeds the number of slots it can show at once. More...
 
virtual bool CanBeShifted (AC_ShiftInventory shiftType)
 Checks if the element's slots can be shifted in a particular direction. More...
 
Vector2 GetSize ()
 Gets the size of the whole element. More...
 
Vector2 GetSizeFromCorner ()
 Gets the Vector2 from the top-left corner of the parent Menu to the bottom-right corner of the element. More...
 
void SetSize (Vector2 _size)
 Sets the size of an individual slot. More...
 
int GetNumSlots ()
 Gets the number of display slots the element has. This is not the maximum number of slots that can be shown by shifting - it is the number of slots that are shown at any one time. More...
 
Rect GetSlotRectRelative (int _slot)
 Gets the boundary of a slot, as a proportion of the screen size. More...
 
virtual void RecalculateSize (MenuSource source)
 Recalculates the element's size. This should be called whenever a Menu's shape is changed. More...
 
int GetFontSize ()
 Gets the size of the font. More...
 
void SetPosition (Vector2 _position)
 Sets the element's position. More...
 
void SetRelativePosition (Vector2 _size)
 
void ResetDragOffset ()
 
void SetDragOffset (Vector2 pos, Rect dragRect)
 Offsets an OnGUI MenuElement's position when dragged by a MenuDrag element. More...
 
Vector2 GetDragStart ()
 Gets the drag offset. More...
 
void AutoSetVisibility ()
 
virtual void SetUIInteractableState (bool state)
 Sets the interactive state of any linked Unity UI gameobjects. More...
 
virtual AudioClip GetHoverSound (int slot)
 Gets the hover sound for the element slot. More...
 
int GetOffset ()
 Gets the amount by which the slots have been offset, if the number that can be shown exceeds the number that can be display at once. More...
 
void SetOffset (int value)
 Sets the amount by which the slots have been offset, if the number that can be shown exceeds the number that can be display at once. More...
 
string GetVisibilitySaveData ()
 
override string ToString ()
 

Public Attributes

Text uiText
 
TextAnchor anchor
 
TextEffects textEffects = TextEffects.None
 
float outlineSize = 2f
 
Color effectColour = Color.black
 
AC_LabelType labelType
 
int variableID
 
bool useCharacterColour = false
 
bool autoAdjustHeight = true
 
bool updateIfEmpty = false
 
bool showPendingWhileMovingToHotspot = false
 
int itemPropertyID
 
bool multiplyByItemCount = false
 
InventoryPropertyType inventoryPropertyType
 
SelectedObjectiveLabelType selectedObjectiveLabelType = SelectedObjectiveLabelType.Title
 
int itemSlotNumber
 
- Public Attributes inherited from AC.MenuElement
int ID
 
string title = "Element"
 
Vector2 slotSize
 
AC_SizeType sizeType
 
AC_PositionType2 positionType
 
float slotSpacing = 0f
 
int lineID = -1
 
string alternativeInputButton = ""
 
Font font
 
float fontScaleFactor = 60f
 
Color fontColor = Color.white
 
Color fontHighlightColor = Color.white
 
bool isClickable
 
ElementOrientation orientation = ElementOrientation.Vertical
 
int gridWidth = 3
 
Texture2D backgroundTexture
 
bool singleSlotBackgrounds = false
 
Texture2D highlightTexture
 
AudioClip hoverSound
 
AudioClip clickSound
 
bool changeCursor = false
 
int cursorID = 0
 
int linkedUiID
 
float maxAutoWidthFactor = 0.5f
 

Protected Member Functions

override void ShowTextGUI (string apiPrefix)
 
override string GetLabelToTranslate ()
 
override void AutoSize ()
 
- Protected Member Functions inherited from AC.MenuElement
void CreateUIEvent (UnityEngine.UI.Button uiButton, AC.Menu _menu, UIPointerState uiPointerState=UIPointerState.PointerClick, int _slotIndex=0, bool liveState=true)
 
void CreateHoverSoundHandler (Selectable selectable, AC.Menu _menu, int _slotIndex=0)
 
virtual void ProcessClickUI (AC.Menu _menu, int _slot, MouseState _mouseState)
 
void ClearCache ()
 
string TranslateLabel (int languageNumber)
 
virtual void ShowTextureGUI (string apiPrefix)
 
void EndGUI (string apiPrefix)
 
void ShowClipHelp ()
 
LinkedUiGUI< T > (T field, string label, MenuSource source, string tooltip="")
 
UISlot[] ResizeUISlots (UISlot[] uiSlots, int maxSlots)
 
void ChangeCursorGUI (Menu menu)
 
void LimitUISlotVisibility (UISlot[] uiSlots, int _numSlots, UIHideStyle uiHideStyle, Texture emptyTexture=null)
 
void LimitUISlotVisibility (UISlot[] uiSlots, int _numSlots, UISelectableHideStyle uiHideStyle)
 
Rect ZoomRect (Rect rect, float zoom)
 
void LimitOffset ()
 
void Shift (AC_ShiftInventory shiftType, int maxSlots, int arraySize, int amount)
 
void SetAbsoluteSize (Vector2 _size)
 
void AutoSize (GUIContent content)
 
void LinkUIElement< T > (Canvas canvas, ref T existingField)
 
void UpdateUISelectable< T > (T field, UISelectableHideStyle uiSelectableHideStyle)
 
void UpdateUIElement< T > (T field)
 
void ClearSpriteCache (UISlot[] uiSlots)
 
void SetUISlotsInteractableState (UISlot[] uiSlots, bool state)
 

Properties

InvInstance OverrideInventoryInstance [set]
 
string label [get, set]
 
- Properties inherited from AC.MenuElement
virtual bool IsVisible [get, set]
 
virtual int MaxSlotsForOffset [get]
 
Menu ParentMenu [get]
 

Additional Inherited Members

- Protected Attributes inherited from AC.MenuElement
bool isVisible = true
 
int offset = 0
 
Menu parentMenu
 
Rect relativeRect
 
Vector2 relativePosition
 
int numSlots
 

Detailed Description

A MenuElement that provides a basic label. The label can be used to display fixed text, or a number of pre-programmed string types, such as the active verb and Hotspot, subtitles, and more. Variable tokens of the form [var:ID] and [localvar:ID] can also be inserted to display the values of global and local variables respectively.

Member Function Documentation

◆ CanTranslate()

bool AC.MenuLabel.CanTranslate ( int  index)

Checks if a given text index can and should be translated.

Parameters
indexThe index of the translatable text
Returns
True if the text can and should be translated

Implements AC.ITranslatable.

◆ CheckConvertGlobalVariableToLocal()

override bool AC.MenuLabel.CheckConvertGlobalVariableToLocal ( int  oldGlobalID,
int  newLocalID 
)
virtual

Checks if the Element makes references from a given global variable to a given local variable

Parameters
oldGlobalIDThe ID number of the old global variable
newLocalIDThe ID number of the new local variable
Returns
True if the Element was affected

Reimplemented from AC.MenuElement.

◆ ClearSpeech()

override void AC.MenuLabel.ClearSpeech ( )
virtual

Clears any speech text on display.

Reimplemented from AC.MenuElement.

◆ Declare()

override void AC.MenuLabel.Declare ( )
virtual

Initialises the MenuElement when it is created within MenuManager.

Reimplemented from AC.MenuElement.

◆ Display()

override void AC.MenuLabel.Display ( GUIStyle  _style,
int  _slot,
float  zoom,
bool  isActive 
)
virtual

Draws the element using OnGUI.

Parameters
_styleThe GUIStyle to draw with
_slotThe index number of the slot to display
zoomThe zoom factor
isActiveIf True, then the element will be drawn as though highlighted

Reimplemented from AC.MenuElement.

◆ DuplicateSelf()

override MenuElement AC.MenuLabel.DuplicateSelf ( bool  fromEditor,
bool  ignoreUnityUI 
)
virtual

Creates and returns a new MenuElement that has the same values as itself.

Parameters
fromEditorIf True, the duplication was done within the Menu Manager and not as part of the gameplay initialisation.
ignoreUnityUIIf True, variables associated with Unity UI will not be transferred
Returns
A new MenuElement with the same values as itself

Reimplemented from AC.MenuElement.

◆ GetLabel()

override string AC.MenuLabel.GetLabel ( int  slot,
int  languageNumber 
)
virtual

Gets the display text of the element, or a slot within it.

Parameters
slotThe index number of the slot to get text for
languageNumberThe index number of the language number to get the text in
Returns
The display text of the element's slot, or the whole element if it only has one slot

Reimplemented from AC.MenuElement.

◆ GetNumTranslatables()

int AC.MenuLabel.GetNumTranslatables ( )

Gets the maximum number of possible translatable texts.

Returns
The maximum number of possible translatable texts.

Implements AC.ITranslatable.

◆ GetOwner()

string AC.MenuLabel.GetOwner ( int  index)

Gets the name of the translatable text's owner. In the case of speech text, it is the name of the character. In the case of menu element text, it is the name of the menu element.

Parameters
indexThe index of the translatable text
Returns
The name of the translatable text's owner.

Implements AC.ITranslatable.

◆ GetRectTransform()

override RectTransform AC.MenuLabel.GetRectTransform ( int  _slot)
virtual

Gets the boundary of the element, or a slot within it.

Parameters
_slotThe index number of the slot to get the boundary of
Returns
The boundary Rect of the slot. If the element doesn't have multiple slots, the boundary of the whole element will be returned.

Reimplemented from AC.MenuElement.

◆ GetSlotIndex()

override int AC.MenuLabel.GetSlotIndex ( GameObject  gameObject)
virtual

Gets the slot index that reference a particular GameObject

Parameters
gameObjectThe GameObject to check for
Returns
The slot index that references the GameObject

Reimplemented from AC.MenuElement.

◆ GetTranslatableString()

string AC.MenuLabel.GetTranslatableString ( int  index)

Gets the text to be translated, given its index.

Parameters
indexThe index of the translatable text
Returns
The text to be translated

Implements AC.ITranslatable.

◆ GetTranslationID()

int AC.MenuLabel.GetTranslationID ( int  index)

Gets the translation ID of a given text index.

Parameters
indexThe index of the translatable text
Returns
The translation ID of the text

Implements AC.ITranslatable.

◆ GetTranslationType()

AC_TextType AC.MenuLabel.GetTranslationType ( int  index)

Gets the translation type of a given text index.

Parameters
indexThe index of the translatable text
Returns
The translation type of a given text index.

Implements AC.ITranslatable.

◆ GetVariableReferences()

override int AC.MenuLabel.GetVariableReferences ( int  varID)
virtual

Gets the number of references the MenuElement makes to a global variable

Parameters
varIDThe global variable's ID number
Returns
The number of references the MenuElement makes to the variable

Reimplemented from AC.MenuElement.

◆ HasExistingTranslation()

bool AC.MenuLabel.HasExistingTranslation ( int  index)

Checks if a given text index has already been assigned a unique translation ID.

Parameters
indexThe index of the translatable text
Returns
True if the text has been assigned a unique translation ID

Implements AC.ITranslatable.

◆ LoadUnityUI()

override void AC.MenuLabel.LoadUnityUI ( AC.Menu  _menu,
Canvas  canvas,
bool  addEventListeners = true 
)
virtual

Initialises the linked Unity UI GameObject.

Parameters
_menuThe element's parent Menu
canvasThe runtime Canvas associated with the Menu
addEventListenersIf True, then event listeners should be added to the UI's Interactive component(s)

Reimplemented from AC.MenuElement.

◆ OnMenuTurnOn()

override void AC.MenuLabel.OnMenuTurnOn ( Menu  menu)
virtual

Called whenever the Menu this is attached to is turned on.

Parameters
menuThe Menu this is attached to

Reimplemented from AC.MenuElement.

◆ OwnerIsPlayer()

bool AC.MenuLabel.OwnerIsPlayer ( int  index)

Checks if the translatable text's owner is a Player. This is necessary for speech lines, since multiple player prefabs can feasibly share the same line.

Parameters
indexThe index of the translatable text
Returns
True if the translatable text's owner is a Player.

Implements AC.ITranslatable.

◆ PreDisplay()

override void AC.MenuLabel.PreDisplay ( int  _slot,
int  languageNumber,
bool  isActive 
)
virtual

Performs all calculations necessary to display the element.

Parameters
_slotThe index number of the slot to display
languageNumberThe index number of the language to display text in
isActiveIf True, then the element will be drawn as though highlighted

Reimplemented from AC.MenuElement.

◆ ReferencesObjectOrID()

override bool AC.MenuLabel.ReferencesObjectOrID ( GameObject  gameObject,
int  id 
)
virtual

Checks if the Element makes reference to a particular GameObject

Parameters
gameObjectThe GameObject to check for
idThe GameObject's associated ConstantID value
Returns
True if the Element references the GameObject

Reimplemented from AC.MenuElement.

◆ SetSpeech()

override void AC.MenuLabel.SetSpeech ( Speech  _speech)
virtual

Assigns the element to a specific Speech line.

Parameters
_speechThe Speech line to assign the element to

Reimplemented from AC.MenuElement.

◆ SetTranslationID()

void AC.MenuLabel.SetTranslationID ( int  index,
int  lineID 
)

Sets the translation ID of a given text index

Parameters
indexThe index of the translatable text
lineIDThe new translation ID to assign the translatable text

Implements AC.ITranslatable.

◆ UpdateLabelText()

void AC.MenuLabel.UpdateLabelText ( int  languageNumber = 0)

Updates the label's text buffer. This is normally done internally at runtime, but can be called manually to update it in Edit mode.

◆ UpdateVariableReferences()

override int AC.MenuLabel.UpdateVariableReferences ( int  oldVarID,
int  newVarID 
)
virtual

Updates references the MenuElement makes to a global variable

Parameters
varIDThe global variable's original ID number
varIDThe global variable's new ID number
Returns
The number of references the MenuElement makes to the variable

Reimplemented from AC.MenuElement.

Member Data Documentation

◆ anchor

TextAnchor AC.MenuLabel.anchor

The text alignement

◆ autoAdjustHeight

bool AC.MenuLabel.autoAdjustHeight = true

If True, and sizeType = AC_SizeType.Manual, then the label's height will adjust itself to fit the text within it

◆ effectColour

Color AC.MenuLabel.effectColour = Color.black

The outline colour

◆ inventoryPropertyType

InventoryPropertyType AC.MenuLabel.inventoryPropertyType

What kind of item to retrieve properties for, if labelType = AC_LabelType.InventoryProperty (SelectedItem, ItemInInventoryBox, LastClickedItem, MouseOverItem)

◆ itemPropertyID

int AC.MenuLabel.itemPropertyID

The ID number of the inventory property to show, if labelType = AC_LabelType.InventoryProperty

◆ itemSlotNumber

int AC.MenuLabel.itemSlotNumber

The InventoryBox slot number to retrieve properties for, if itemInInventoryBox = ItemInInventoryBox.ItemInSlot

◆ labelType

AC_LabelType AC.MenuLabel.labelType

What kind of text the label displays (Normal, Hotspot, DialogueLine, DialogueSpeaker, GlobalVariable, ActiveSaveProfile, JournalPageNumber, InventoryProperty, DocumentTitle, SelectedObjective)

◆ multiplyByItemCount

bool AC.MenuLabel.multiplyByItemCount = false

If True, and labelType = AC_LabelType.InventoryProperty, then the total property value will be multipled by the count associated with the item

◆ outlineSize

float AC.MenuLabel.outlineSize = 2f

The outline thickness, if textEffects != TextEffects.None

◆ selectedObjectiveLabelType

SelectedObjectiveLabelType AC.MenuLabel.selectedObjectiveLabelType = SelectedObjectiveLabelType.Title

What Objective text to display, if labelType = AC_LabelType.SelectedObjective

◆ showPendingWhileMovingToHotspot

bool AC.MenuLabel.showPendingWhileMovingToHotspot = false

If True, and labelType = AC_LabelType.Hotspot, then the label will not change while the player is moving towards a Hotspot in order to run an interaction

◆ textEffects

TextEffects AC.MenuLabel.textEffects = TextEffects.None

The special FX applied to the text (None, Outline, Shadow, OutlineAndShadow)

◆ uiText

Text AC.MenuLabel.uiText

The Unity UI Text this is linked to (Unity UI Menus only)

◆ updateIfEmpty

bool AC.MenuLabel.updateIfEmpty = false

If True, and labelType = AC_LabelType.Hotspot, DialogueSpeaker or DialogueLine, then the display text buffer can be empty

◆ useCharacterColour

bool AC.MenuLabel.useCharacterColour = false

If True, and labelType = AC_LabelType.DialogueLine, then the displayed subtitle text will use the speaking character's subtitle text colour

◆ variableID

int AC.MenuLabel.variableID

The ID number of the global variable to show (if labelType = AC_LabelType.GlobalVariable)

Property Documentation

◆ label

string AC.MenuLabel.label
getset

The display text, if labelType = AC_LabelType.Normal

◆ OverrideInventoryInstance

InvInstance AC.MenuLabel.OverrideInventoryInstance
set

The Inventory instance to rely on if inventoryPropertyType = InventoryPropertyType.CustomScript