SHARE
TWEET

Untitled

a guest Aug 19th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3.  
  4. public abstract class Observer : MonoBehaviour
  5. {
  6.     //Notify
  7.     public abstract void OnNotify(string value);
  8. }
  9.  
  10. public abstract class Subject : MonoBehaviour
  11. {
  12.     //List semua observer
  13.     private List<Observer> _observers = new List<Observer>();
  14.  
  15.     //Register semua observer
  16.     public void RegisterObserver(Observer observer)
  17.     {
  18.         _observers.Add(observer);
  19.     }
  20.    
  21.     //Notify
  22.     public void Notify(string value)
  23.     {
  24.         foreach (var observer in _observers)
  25.             observer.OnNotify(value);
  26.     }
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top