public void Awake() { if (this.myCustomEvent == null) { this.myCustomEvent = new MyCustomUnityEvent(); } }
public void OnDisable() { this.myEvents.myCustomEvent -= MyMethod; }
// Allows to drag and drop the slower Unity Event on the // faster delegate events when needed. // If you only work via scripting you get the faster // delegate events. If you work via drag and drop // you take a small overhead by calling the UnityEvent in the delegate. public void OnEnable() { this.myEvents = base.GetComponent <CSharpEvents>(); this.myEvents.myCustomEvent += MyMethod; }