3using UnityEngine.EventSystems;
6public class UIInventorySlot : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
85 m_GridCursor.SelectedItemType =
ItemType.None;
160 Vector3 worldPosiiton =
m_MainCamera.ScreenToWorldPoint(
new Vector3( Input.mousePosition.x, Input.mousePosition.y, -
m_MainCamera.transform.position.z ) );
164 Item item = itemGameObject.GetComponent<
Item>();
194 Image draggedItemImage =
m_DraggedItem.GetComponentInChildren<Image>();
205 public void OnDrag( PointerEventData eventData )
209 m_DraggedItem.transform.position = Input.mousePosition;
225 if( eventData.pointerCurrentRaycast.gameObject !=
null && eventData.pointerCurrentRaycast.gameObject.GetComponent<
UIInventorySlot>() !=
null )
257 if( eventData.button == PointerEventData.InputButton.Left )
283 m_InventoryBar.m_InventoryTextBoxGameObject = Instantiate(
m_InventoryTextBoxPrefab, transform.position, Quaternion.identity );
298 m_InventoryBar.m_InventoryTextBoxGameObject.transform.position =
new Vector3( transform.position.x, transform.position.y + 50f, transform.position.z );
303 m_InventoryBar.m_InventoryTextBoxGameObject.transform.position =
new Vector3(transform.position.x, transform.position.y - 50f, transform.position.z);
InventoryLocation
Describes the type of inventory and count Ex: player inventory or chest inventory
ItemType
Describe the item type
void DisableCursor()
Disable the cursor.
void EnableCursor()
Enable the cursor.
bool CursorPositionIsValid
This class will manage all the inventory related operations.
This class holds information of items.
short m_ItemUseGridRadius
string m_ItemLongDescription
This class has all the things related to player
This class handle the game settings.
const float m_GridCellSize
Grid cell size in unity units.
void ClearHighlightOnInventorySlots()
Clear all highlights from the inventory bar.
bool IsInventoryBarPositionBottom
GameObject m_InventoryTextBoxGameObject
GameObject m_InventoryBarDraggedItem
void SetHighlightedInventorySlots()
Set the selected highlight if set on all inventory item position
GameObject m_InventoryTextBoxPrefab
void Start()
Call after the awake Initialize main camera.
void DestroyInventoryTextBox()
Destroy gameobject when we hover away from the inventory slot.
void OnPointerClick(PointerEventData eventData)
If we click an item in the inventory set it or clear it another is already selected.
void DropSelectedItemAtMousePosition()
Drop the item (if selected) at the current mouse position. Called by drop item event
UIInventoryBar m_InventoryBar
void ClearCursors()
Disable the cursor and change item type to none.
void OnPointerExit(PointerEventData eventData)
Call the function to destroy the gameobject. Once we hover away from the inventory slot,...
void OnBeginDrag(PointerEventData eventData)
Begin executing when we start to dran an item from the inventory bar
void Awake()
Get called when the script is loaded. Initialize the parent canvas.
void SceneLoaded()
When we add a new scene, we lost the previous game object and therefore need to find it again....
Image m_InventorySlotImage
ItemDetails m_ItemDetails
void OnDisable()
Unsubscribe from the AfterSceneLoadEvent event.
void OnPointerEnter(PointerEventData eventData)
Populate TextBox with item details.
void OnEndDrag(PointerEventData eventData)
If item is droppable, drop the item otherwise destroy it.
Image m_InventorySlotHighlight
TextMeshProUGUI m_TextMeshProUGUI
void OnDrag(PointerEventData eventData)
Move gameobject as dragged item.
void SetSelectedItem()
Sets this inventory slot item to be selected
void ClearSelectedItem()
Clear currently highlighted items
void OnEnable()
Subscribe to the AfterSceneLoadEvent event.
void SetTextBoxText(string textTop1, string textTop2, string textTop3, string textBottom1, string textBottom2, string textBottom3)
Set Text Values