Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Sirenix.OdinInspector;
- using System;
- using System.Collections.Generic;
- using UnityEngine.Events;
- [Serializable]
- public struct BetterEvent
- {
- [HideReferenceObjectPicker, ListDrawerSettings(CustomAddFunction = "GetDefaultBetterEvent", OnTitleBarGUI = "DrawInvokeButton")]
- public List<BetterEventEntry> Events;
- public void Invoke()
- {
- if (this.Events == null) return;
- for (int i = 0; i < this.Events.Count; i++)
- {
- this.Events[i].Invoke();
- }
- }
- public void AddCallback(UnityAction callback)
- {
- if (Events == null)
- Events = new List<BetterEventEntry>();
- Events.Add(new BetterEventEntry(callback));
- }
- #if UNITY_EDITOR
- private BetterEventEntry GetDefaultBetterEvent()
- {
- return new BetterEventEntry(null);
- }
- private void DrawInvokeButton()
- {
- if (Sirenix.Utilities.Editor.SirenixEditorGUI.ToolbarButton("Invoke"))
- {
- this.Invoke();
- }
- }
- #endif
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement