evelynshilosky

StorageInteractable - Part 6.1

Mar 27th, 2025
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 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.InitializeStorage(item);
  22.             StorageSystem.Instance.RegisterStorage(item, storageHolder);
  23.         }
  24.         else
  25.         {
  26.             Debug.LogError("StorageInteractable is missing item or storageHolder reference.");
  27.         }
  28.     }
  29.  
  30.     public override void Interact(PlayerMovement playerMovement, bool isRightClick)
  31.     {
  32.         if (isRightClick)
  33.         {
  34.             UIManager.Instance.ShowInventoryPrompt(item);
  35.         }
  36.         else
  37.         {
  38.             base.Interact(playerMovement, isRightClick);
  39.         }
  40.     }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment