CursorHolderBehaviour
user_3183455
csharp
a year ago
1.5 kB
5
Indexable
using CuongMono.Item.Inventory; using UnityEngine; namespace CuongMono.Item { public class CursorHolderBehaviour : MonoBehaviour { public bool IsPickedUp { get; set; } [SerializeField] private CursorInventoryItemSlotUI inventoryItemSlotUI; public CursorInventoryItemSlotUI InventoryItemSlotUI => inventoryItemSlotUI; //[SerializeField] private HotbarItemSlotUI hotbarItemSlotUI; //public HotbarItemSlotUI HotbarItemSlotUI => hotbarItemSlotUI; private void Update() { this.CheckItem(); this.CursorBehaviour(); } protected virtual void CursorBehaviour() { if (this.IsPickedUp) this.FollowCursor(); } public virtual void UpdateUI() { this.InventoryItemSlotUI.UpdateUI(); //this.HotbarItemSlotUI?.UpdateUI(); } protected virtual void CheckItem() { if(this.InventoryItemSlotUI?.Item != null /*|| this.HotbarItemSlotUI?.Item != null*/) this.IsPickedUp = true; else this.IsPickedUp = false; } protected virtual void FollowCursor() { if (this.InventoryItemSlotUI == null /*|| this.HotbarItemSlotUI == null*/) return; this.InventoryItemSlotUI.transform.position = Input.mousePosition; //this.HotbarItemSlotUI.transform.position = Input.mousePosition; } } }
Editor is loading...
Leave a Comment