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

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)
 Initialises the linked Unity UI GameObjects. More...
 
UnityEngine.UI.Button GetUIButtonWithItem (int itemID)
 Gets the UI Button associated with an inventory item, provided that the Menus' Source is UnityUiPrefab or UnityUiInScene. More...
 
override GameObject GetObjectToSelect (int slotIndex=0)
 Gets the linked Unity UI GameObject associated with this element. More...
 
override RectTransform GetRectTransform (int _slot)
 Gets the boundary of the slot More...
 
override void ShowGUI (Menu menu)
 
override void HideAllUISlots ()
 
override void SetUIInteractableState (bool state)
 Sets the interactive state of any linked Unity UI gameobjects. More...
 
override void PreDisplay (int _slot, int languageNumber, bool isActive)
 Performs all calculations necessary to display the element. More...
 
override void Display (GUIStyle _style, int _slot, float zoom, bool isActive)
 Draws the element using OnGUI More...
 
void HandleDefaultClick (MouseState _mouseState, int _slot, AC_InteractionMethod interactionMethod)
 Performs what should happen when the element is clicked on, if inventoryBoxType = AC_InventoryBoxType.Default. More...
 
override void RecalculateSize (MenuSource source)
 Recalculates the element's size. This should be called whenever a Menu's shape is changed. More...
 
override bool CanBeShifted (AC_ShiftInventory shiftType)
 Checks if the element's slots can be shifted in a particular direction. More...
 
override 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...
 
override string GetLabel (int i, int languageNumber)
 Gets the display text of the element More...
 
override bool IsSelectedByEventSystem (int slotIndex)
 Checks if the element is selected by Unity UI's EventSystem. More...
 
InvItem GetItem (int i)
 Gets the inventory item shown in a specific slot More...
 
void ResetOffset ()
 
void ClickContainer (MouseState _mouseState, int _slot)
 Performs what should happen when the element is clicked on, if inventoryBoxType = AC_InventoryBoxType.Container. More...
 
override void ProcessClick (AC.Menu _menu, int _slot, MouseState _mouseState)
 Performs what should happen when the element is clicked on. More...
 
Document GetDocument (int slotIndex)
 Gets the Document associated with a given slot More...
 
int GetItemSlot (int itemID)
 Gets the slot index number that a given InvItem (inventory item) appears in. 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 void ProcessContinuousClick (AC.Menu _menu, MouseState _mouseState)
 Performs what should happen when the element is clicked on continuously. More...
 
virtual void SetSpeech (Speech _speech)
 Assigns the element to a specific Speech line. More...
 
virtual void SetHotspot (Hotspot _hotspot, InvItem _invItem)
 Assigns the element to a specific Hotspot.
 
virtual void ClearSpeech ()
 
void UpdateID (int[] idArray)
 Updates the ID number to something unique. More...
 
void ShowGUIStart (Menu menu)
 
virtual bool CheckConvertGlobalVariableToLocal (int oldGlobalID, int newLocalID)
 Checks if the Elements makesreferences from a given global variable to a given local variable More...
 
virtual int GetVariableReferences (int varID)
 Gets the number of references the MenuElement makes to a global variable 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...
 
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...
 
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 ()
 
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...
 
virtual void OnMenuTurnOn (Menu menu)
 Called whenever the Menu this is attached to is turned on. More...
 

Public Attributes

UISlot [] uiSlots
 
UIPointerState uiPointerState = UIPointerState.PointerClick
 
TextEffects textEffects
 
TextAnchor anchor = TextAnchor.MiddleCenter
 
float outlineSize = 2f
 
AC_InventoryBoxType inventoryBoxType
 
int maxSlots
 
bool limitToCategory
 
bool limitToDefinedInteractions = true
 
int categoryID
 
List< int > categoryIDs = new List<int>()
 
LinkUIGraphic linkUIGraphic = LinkUIGraphic.ImageComponent
 
bool preventInteractions = false
 
bool limitMaxScroll = true
 
bool updateHotspotLabelWhenHover = false
 
List< InvItemitems = new List<InvItem>()
 
bool selectItemsAfterTaking = true
 
ConversationDisplayType displayType = ConversationDisplayType.IconOnly
 
UIHideStyle uiHideStyle = UIHideStyle.DisableObject
 
bool autoOpenDocument = true
 
- Public Attributes inherited from AC.MenuElement
int ID
 
bool isEditing = false
 
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
 

Protected Member Functions

override void ShowTextureGUI (string apiPrefix)
 
override void ShowTextGUI (string apiPrefix)
 
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 ProcessClickUI (AC.Menu _menu, int _slot, MouseState _mouseState)
 
string TranslateLabel (string label, int languageNumber)
 
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)
 
Rect ZoomRect (Rect rect, float zoom)
 
void LimitOffset (int maxValue)
 
void Shift (AC_ShiftInventory shiftType, int maxSlots, int arraySize, int amount)
 
void SetAbsoluteSize (Vector2 _size)
 
void AutoSize (GUIContent content)
 
LinkUIElement< T > (Canvas canvas)
 
void UpdateUISelectable< T > (T field, UISelectableHideStyle uiSelectableHideStyle)
 
void UpdateUIElement< T > (T field)
 
void ClearSpriteCache (UISlot[] uiSlots)
 
void SetUISlotsInteractableState (UISlot[] uiSlots, bool state)
 

Properties

Container OverrideContainer [set]
 
- Properties inherited from AC.MenuElement
bool IsVisible [get, set]
 
string IDString [get]
 

Additional Inherited Members

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

Detailed Description

A MenuElement that lists inventory items (see: InvItem). It can be used to display all inventory items held by the player, those that are stored within a Container, or as part of an Interaction Menu.

Member Function Documentation

◆ CanBeShifted()

override bool AC.MenuInventoryBox.CanBeShifted ( AC_ShiftInventory  shiftType)
virtual

Checks if the element's slots can be shifted in a particular direction.

Parameters
shiftTypeThe direction to shift slots in (Left, Right)
Returns
True if the element's slots can be shifted in the particular direction

Reimplemented from AC.MenuElement.

◆ ClickContainer()

void AC.MenuInventoryBox.ClickContainer ( MouseState  _mouseState,
int  _slot 
)

Performs what should happen when the element is clicked on, if inventoryBoxType = AC_InventoryBoxType.Container.

Parameters
_mouseStateThe state of the mouse button
_slotThe index number of the slot that was clicked on

◆ Declare()

override void AC.MenuInventoryBox.Declare ( )
virtual

Initialises the element when it is created within MenuManager.

Reimplemented from AC.MenuElement.

◆ Display()

override void AC.MenuInventoryBox.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

<param name = "isActive If True, then the element will be drawn as though highlighted

Reimplemented from AC.MenuElement.

◆ DuplicateSelf()

override MenuElement AC.MenuInventoryBox.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.

◆ GetDocument()

Document AC.MenuInventoryBox.GetDocument ( int  slotIndex)

Gets the Document associated with a given slot

Parameters
slotIndexThe element's slot index number
Returns
The Document assoicated with the slot

◆ GetItem()

InvItem AC.MenuInventoryBox.GetItem ( int  i)

Gets the inventory item shown in a specific slot

Parameters
iThe index number of the slot
Returns
The inventory item shown in the slot

◆ GetItemSlot()

int AC.MenuInventoryBox.GetItemSlot ( int  itemID)

Gets the slot index number that a given InvItem (inventory item) appears in.

Parameters
itemIDThe ID number of the InvItem to search for
Returns
The slot index number that the inventory item appears in

◆ GetLabel()

override string AC.MenuInventoryBox.GetLabel ( int  i,
int  languageNumber 
)
virtual

Gets the display text of the element

Parameters
slotThe index number of the slot
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.

◆ GetObjectToSelect()

override GameObject AC.MenuInventoryBox.GetObjectToSelect ( int  slotIndex = 0)
virtual

Gets the linked Unity UI GameObject associated with this element.

Returns
The Unity UI GameObject associated with the element

Reimplemented from AC.MenuElement.

◆ GetRectTransform()

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

Gets the boundary of the slot

Parameters
_slotThe index number of the slot to get the boundary of
Returns
The boundary Rect of the slot

Reimplemented from AC.MenuElement.

◆ GetUIButtonWithItem()

UnityEngine.UI.Button AC.MenuInventoryBox.GetUIButtonWithItem ( int  itemID)

Gets the UI Button associated with an inventory item, provided that the Menus' Source is UnityUiPrefab or UnityUiInScene.

Parameters
itemIDThe ID number of the inventory item (InvItem) to search for
Returns
The UI Button associated with an inventory item, or null if a suitable Button cannot be found.

◆ HandleDefaultClick()

void AC.MenuInventoryBox.HandleDefaultClick ( MouseState  _mouseState,
int  _slot,
AC_InteractionMethod  interactionMethod 
)

Performs what should happen when the element is clicked on, if inventoryBoxType = AC_InventoryBoxType.Default.

Parameters
_mouseStateThe state of the mouse button
_slotThe index number of the slot that was clicked on
interactionMethodThe game's interaction method (ContextSensitive, ChooseHotspotThenInteraction, ChooseInteractionThenHotspot)

◆ HideAllUISlots()

override void AC.MenuInventoryBox.HideAllUISlots ( )
virtual

Hides all linked Unity UI GameObjects associated with the element.

Reimplemented from AC.MenuElement.

◆ IsSelectedByEventSystem()

override bool AC.MenuInventoryBox.IsSelectedByEventSystem ( int  slotIndex)
virtual

Checks if the element is selected by Unity UI's EventSystem.

Parameters
slotIndexThe element's slot index, if it has multiple slots
Returns
True if the element is selected by Unity UI's EventSystem.

Reimplemented from AC.MenuElement.

◆ LoadUnityUI()

override void AC.MenuInventoryBox.LoadUnityUI ( AC.Menu  _menu,
Canvas  canvas 
)
virtual

Initialises the linked Unity UI GameObjects.

Parameters
_menuThe element's parent Menu

Reimplemented from AC.MenuElement.

◆ PreDisplay()

override void AC.MenuInventoryBox.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.

◆ ProcessClick()

override void AC.MenuInventoryBox.ProcessClick ( AC.Menu  _menu,
int  _slot,
MouseState  _mouseState 
)
virtual

Performs what should happen when the element is clicked on.

Parameters
_menuThe element's parent Menu
_slotThe index number of ths slot that was clicked

<param name = "_mouseState The state of the mouse button

Reimplemented from AC.MenuElement.

◆ RecalculateSize()

override void AC.MenuInventoryBox.RecalculateSize ( MenuSource  source)
virtual

Recalculates the element's size. This should be called whenever a Menu's shape is changed.

Parameters
sourceHow the parent Menu is displayed (AdventureCreator, UnityUiPrefab, UnityUiInScene)

Reimplemented from AC.MenuElement.

◆ ResetOffset()

void AC.MenuInventoryBox.ResetOffset ( )

Re-sets the "shift" offset, so that the first InvItem shown is the first InvItem in items.

◆ SetUIInteractableState()

override void AC.MenuInventoryBox.SetUIInteractableState ( bool  state)
virtual

Sets the interactive state of any linked Unity UI gameobjects.

Parameters
stateIf True, linked UI gameobjects will be made interactive. If False, they will be made non-interactive

Reimplemented from AC.MenuElement.

◆ Shift()

override void AC.MenuInventoryBox.Shift ( AC_ShiftInventory  shiftType,
int  amount 
)
virtual

Shifts which slots are on display, if the number of slots the element has exceeds the number of slots it can show at once.

Parameters
shiftTypeThe direction to shift slots in (Left, Right)
amountThe amount to shift slots by

Reimplemented from AC.MenuElement.

Member Data Documentation

◆ anchor

TextAnchor AC.MenuInventoryBox.anchor = TextAnchor.MiddleCenter

The text alignement, if displayType = ConversationDisplayType.TextOnly

◆ autoOpenDocument

bool AC.MenuInventoryBox.autoOpenDocument = true

If True, and inventoryBoxType = AC_InventoryBoxType.CollectedDocuments, then clicking an element slot will open the chosen Document

◆ categoryID

int AC.MenuInventoryBox.categoryID

The category ID to limit the display of inventory items by, if limitToCategory = True (Deprecated)

◆ categoryIDs

List<int> AC.MenuInventoryBox.categoryIDs = new List<int>()

The category IDs to limit the display of inventory items by, if limitToCategory = True

◆ displayType

ConversationDisplayType AC.MenuInventoryBox.displayType = ConversationDisplayType.IconOnly

How items are displayed (IconOnly, TextOnly, IconAndText)

◆ inventoryBoxType

AC_InventoryBoxType AC.MenuInventoryBox.inventoryBoxType

How the items to display are chosen (Default, HotspotBased, CustomScript, DisplaySelected, DisplayLastSelected, Container, CollectedDocuments)

◆ items

List<InvItem> AC.MenuInventoryBox.items = new List<InvItem>()

The List of inventory items that are on display

◆ limitMaxScroll

bool AC.MenuInventoryBox.limitMaxScroll = true

If True, and the element is scrolled by an offset larger than the number of new items to show, then the offset amount will be reduced to only show those new items.

◆ limitToCategory

bool AC.MenuInventoryBox.limitToCategory

If True, only inventory items (InvItem) with a specific category will be displayed

◆ limitToDefinedInteractions

bool AC.MenuInventoryBox.limitToDefinedInteractions = true

If True, then only inventory items that are listed in a Hotspot's / InvItem's interactions will be listed if inventoryBoxType = AC_InventoryBoxType.HotspotBased

◆ linkUIGraphic

LinkUIGraphic AC.MenuInventoryBox.linkUIGraphic = LinkUIGraphic.ImageComponent

What Image component the Element's Graphics should be linked to (ImageComponent, ButtonTargetGraphic)

◆ maxSlots

int AC.MenuInventoryBox.maxSlots

The maximum number of inventory items that can be shown at once

◆ outlineSize

float AC.MenuInventoryBox.outlineSize = 2f

The outline thickness, if textEffects != TextEffects.None

◆ preventInteractions

bool AC.MenuInventoryBox.preventInteractions = false

If True, then no interactions will work, but items can still be selected and re-arranged as normal

◆ selectItemsAfterTaking

bool AC.MenuInventoryBox.selectItemsAfterTaking = true

If True, and inventoryBoxType = AC_InventoryBoxType.Container, then items will be selected automatically when they are removed from the container

◆ textEffects

TextEffects AC.MenuInventoryBox.textEffects

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

◆ uiHideStyle

UIHideStyle AC.MenuInventoryBox.uiHideStyle = UIHideStyle.DisableObject

The method by which this element (or slots within it) are hidden from view when made invisible (DisableObject, ClearContent)

◆ uiPointerState

UIPointerState AC.MenuInventoryBox.uiPointerState = UIPointerState.PointerClick

What pointer state registers as a 'click' for Unity UI Menus (PointerClick, PointerDown, PointerEnter)

◆ uiSlots

UISlot [] AC.MenuInventoryBox.uiSlots

A List of UISlot classes that reference the linked Unity UI GameObjects (Unity UI Menus only)

◆ updateHotspotLabelWhenHover

bool AC.MenuInventoryBox.updateHotspotLabelWhenHover = false

DisplayType != ConversationDisplayType.IconOnly, Hotspot labels will only update when hovering over items if this is True

Property Documentation

◆ OverrideContainer

Container AC.MenuInventoryBox.OverrideContainer
set

If set, and inventoryBoxType = AC_InventoryBoxType.Container, then this Container will be used instead of the global 'active' one. Note that its Menu's 'Appear type' should not be set to 'On Container'.