A 2D Farming RPG
This is just a simple 2D farming RPG game
Loading...
Searching...
No Matches
UIInventorySlot Class Reference
Inheritance diagram for UIInventorySlot:
Inheritance graph
Collaboration diagram for UIInventorySlot:
Collaboration graph

Public Member Functions

void OnBeginDrag (PointerEventData eventData)
 Begin executing when we start to dran an item from the inventory bar More...
 
void OnDrag (PointerEventData eventData)
 Move gameobject as dragged item. More...
 
void OnEndDrag (PointerEventData eventData)
 If item is droppable, drop the item otherwise destroy it. More...
 
void OnPointerClick (PointerEventData eventData)
 If we click an item in the inventory set it or clear it another is already selected. More...
 
void OnPointerEnter (PointerEventData eventData)
 Populate TextBox with item details. More...
 
void OnPointerExit (PointerEventData eventData)
 Call the function to destroy the gameobject. Once we hover away from the inventory slot, we don't need to see the item description anymore. More...
 
void DestroyInventoryTextBox ()
 Destroy gameobject when we hover away from the inventory slot. More...
 
void SceneLoaded ()
 When we add a new scene, we lost the previous game object and therefore need to find it again. Otherwise, we can't throw items from inventory to ground. More...
 

Data Fields

Image m_InventorySlotHighlight
 
Image m_InventorySlotImage
 
TextMeshProUGUI m_TextMeshProUGUI
 
ItemDetails m_ItemDetails
 
int m_ItemQuantity
 
bool m_IsSelected = false
 

Private Member Functions

void Awake ()
 Get called when the script is loaded. Initialize the parent canvas. More...
 
void OnDisable ()
 Unsubscribe from the AfterSceneLoadEvent event. More...
 
void OnEnable ()
 Subscribe to the AfterSceneLoadEvent event. More...
 
void Start ()
 Call after the awake Initialize main camera. More...
 
void ClearCursors ()
 Disable the cursor and change item type to none. More...
 
void SetSelectedItem ()
 Sets this inventory slot item to be selected More...
 
void ClearSelectedItem ()
 Clear currently highlighted items More...
 
void DropSelectedItemAtMousePosition ()
 Drop the item (if selected) at the current mouse position. Called by drop item event More...
 

Private Attributes

Camera m_MainCamera
 
Transform m_ParentItem
 
GameObject m_DraggedItem
 
GridCursor m_GridCursor
 
Canvas m_ParentCanvas
 
UIInventoryBar m_InventoryBar
 
GameObject m_InventoryTextBoxPrefab = null
 
GameObject m_ItemPrefab = null
 
int m_SlotNumber = 0
 

Detailed Description

Definition at line 6 of file UIInventorySlot.cs.

Member Function Documentation

◆ Awake()

void UIInventorySlot.Awake ( )
inlineprivate

Get called when the script is loaded. Initialize the parent canvas.

Definition at line 43 of file UIInventorySlot.cs.

◆ ClearCursors()

void UIInventorySlot.ClearCursors ( )
inlineprivate

Disable the cursor and change item type to none.

Definition at line 79 of file UIInventorySlot.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearSelectedItem()

void UIInventorySlot.ClearSelectedItem ( )
inlineprivate

Clear currently highlighted items

Definition at line 135 of file UIInventorySlot.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DestroyInventoryTextBox()

void UIInventorySlot.DestroyInventoryTextBox ( )
inline

Destroy gameobject when we hover away from the inventory slot.

Definition at line 322 of file UIInventorySlot.cs.

Here is the caller graph for this function:

◆ DropSelectedItemAtMousePosition()

void UIInventorySlot.DropSelectedItemAtMousePosition ( )
inlineprivate

Drop the item (if selected) at the current mouse position. Called by drop item event

Definition at line 153 of file UIInventorySlot.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnBeginDrag()

void UIInventorySlot.OnBeginDrag ( PointerEventData  eventData)
inline

Begin executing when we start to dran an item from the inventory bar

Parameters
eventData

Definition at line 183 of file UIInventorySlot.cs.

Here is the call graph for this function:

◆ OnDisable()

void UIInventorySlot.OnDisable ( )
inlineprivate

Unsubscribe from the AfterSceneLoadEvent event.

Definition at line 51 of file UIInventorySlot.cs.

Here is the call graph for this function:

◆ OnDrag()

void UIInventorySlot.OnDrag ( PointerEventData  eventData)
inline

Move gameobject as dragged item.

Parameters
eventData

Definition at line 205 of file UIInventorySlot.cs.

◆ OnEnable()

void UIInventorySlot.OnEnable ( )
inlineprivate

Subscribe to the AfterSceneLoadEvent event.

Definition at line 60 of file UIInventorySlot.cs.

Here is the call graph for this function:

◆ OnEndDrag()

void UIInventorySlot.OnEndDrag ( PointerEventData  eventData)
inline

If item is droppable, drop the item otherwise destroy it.

Parameters
eventData

Definition at line 217 of file UIInventorySlot.cs.

Here is the call graph for this function:

◆ OnPointerClick()

void UIInventorySlot.OnPointerClick ( PointerEventData  eventData)
inline

If we click an item in the inventory set it or clear it another is already selected.

Parameters
eventData

Definition at line 255 of file UIInventorySlot.cs.

Here is the call graph for this function:

◆ OnPointerEnter()

void UIInventorySlot.OnPointerEnter ( PointerEventData  eventData)
inline

Populate TextBox with item details.

Parameters
eventData

Definition at line 278 of file UIInventorySlot.cs.

Here is the call graph for this function:

◆ OnPointerExit()

void UIInventorySlot.OnPointerExit ( PointerEventData  eventData)
inline

Call the function to destroy the gameobject. Once we hover away from the inventory slot, we don't need to see the item description anymore.

Parameters
eventData

Definition at line 314 of file UIInventorySlot.cs.

Here is the call graph for this function:

◆ SceneLoaded()

void UIInventorySlot.SceneLoaded ( )
inline

When we add a new scene, we lost the previous game object and therefore need to find it again. Otherwise, we can't throw items from inventory to ground.

Definition at line 334 of file UIInventorySlot.cs.

Here is the caller graph for this function:

◆ SetSelectedItem()

void UIInventorySlot.SetSelectedItem ( )
inlineprivate

Sets this inventory slot item to be selected

Definition at line 91 of file UIInventorySlot.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Start()

void UIInventorySlot.Start ( )
inlineprivate

Call after the awake Initialize main camera.

Definition at line 70 of file UIInventorySlot.cs.

Field Documentation

◆ m_DraggedItem

GameObject UIInventorySlot.m_DraggedItem
private

Definition at line 23 of file UIInventorySlot.cs.

◆ m_GridCursor

GridCursor UIInventorySlot.m_GridCursor
private

Definition at line 24 of file UIInventorySlot.cs.

◆ m_InventoryBar

UIInventoryBar UIInventorySlot.m_InventoryBar
private

Definition at line 28 of file UIInventorySlot.cs.

◆ m_InventorySlotHighlight

Image UIInventorySlot.m_InventorySlotHighlight

Definition at line 8 of file UIInventorySlot.cs.

◆ m_InventorySlotImage

Image UIInventorySlot.m_InventorySlotImage

Definition at line 9 of file UIInventorySlot.cs.

◆ m_InventoryTextBoxPrefab

GameObject UIInventorySlot.m_InventoryTextBoxPrefab = null
private

Definition at line 31 of file UIInventorySlot.cs.

◆ m_IsSelected

bool UIInventorySlot.m_IsSelected = false

Definition at line 19 of file UIInventorySlot.cs.

◆ m_ItemDetails

ItemDetails UIInventorySlot.m_ItemDetails

Definition at line 13 of file UIInventorySlot.cs.

◆ m_ItemPrefab

GameObject UIInventorySlot.m_ItemPrefab = null
private

Definition at line 34 of file UIInventorySlot.cs.

◆ m_ItemQuantity

int UIInventorySlot.m_ItemQuantity

Definition at line 16 of file UIInventorySlot.cs.

◆ m_MainCamera

Camera UIInventorySlot.m_MainCamera
private

Definition at line 21 of file UIInventorySlot.cs.

◆ m_ParentCanvas

Canvas UIInventorySlot.m_ParentCanvas
private

Definition at line 25 of file UIInventorySlot.cs.

◆ m_ParentItem

Transform UIInventorySlot.m_ParentItem
private

Definition at line 22 of file UIInventorySlot.cs.

◆ m_SlotNumber

int UIInventorySlot.m_SlotNumber = 0
private

Definition at line 37 of file UIInventorySlot.cs.

◆ m_TextMeshProUGUI

TextMeshProUGUI UIInventorySlot.m_TextMeshProUGUI

Definition at line 10 of file UIInventorySlot.cs.


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