Advertisement
Guest User

Untitled

a guest
Jun 21st, 2021
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. namespace GameStudioName
  4. {
  5.     public class InventoryNotifier : MonoBehaviour
  6.     {
  7.         [SerializeField] private InventoryFilters filter;
  8.         [SerializeField] private GameObject notifyIconPrefab;
  9.         [SerializeField] private Transform notifyIconContainer;
  10.  
  11.         private GameObject notifyIcon;
  12.  
  13.         public InventoryFilters Filter => filter;
  14.  
  15.         private void Start()
  16.         {
  17.             InventoryWatcher.Current.RegisterNotifier(this);
  18.         }
  19.  
  20.         public void OnNotify(bool enabled)
  21.         {
  22.             if (enabled && notifyIcon == null)
  23.                 notifyIcon = Instantiate(notifyIconPrefab, notifyIconContainer, false);
  24.             else if (!enabled && notifyIcon != null)
  25.                 Destroy(notifyIcon);
  26.         }
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement