evelynshilosky

StorageInteractable - Part 3 & 4

Feb 7th, 2025
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class StorageInteractable : InteractableObject
  4. {
  5.     public Transform storageHolder;
  6.  
  7.     private void Awake()
  8.     {
  9.         item = GetComponent<Item>();
  10.         if (item == null)
  11.         {
  12.             Debug.LogError("StorageInteractable requires an Item component on the same GameObject.");
  13.             enabled = false;
  14.         }
  15.     }
  16.  
  17.     private void Start()
  18.     {
  19.         if (item != null && storageHolder != null)
  20.         {
  21.             StorageSystem.Instance.RegisterStorage(item, storageHolder);
  22.         }
  23.         else
  24.         {
  25.             Debug.LogError("StorageInteractable is missing item or storageHolder reference.");
  26.         }
  27.     }
  28.  
  29.     public override void Interact(PlayerMovement playerMovement, bool isRightClick)
  30.     {
  31.         if (isRightClick)
  32.         {
  33.             UIManager.Instance.ShowInventoryPrompt(item);
  34.         }
  35.         else
  36.         {
  37.             base.Interact(playerMovement, isRightClick);
  38.         }
  39.     }
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment