From 5f9e8f979deb94e9219113ed09b49142c040cb57 Mon Sep 17 00:00:00 2001 From: Simon O'Shea Date: Mon, 31 Jul 2023 18:45:01 -0400 Subject: import successful, grid has visuals cell values and grid lines are displayed. no interaction available yet. --- .../CodeMonkey/MonoBehaviours/ComponentActions.cs | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Pathfinding Visualizer/Assets/CodeMonkey/MonoBehaviours/ComponentActions.cs (limited to 'Pathfinding Visualizer/Assets/CodeMonkey/MonoBehaviours/ComponentActions.cs') diff --git a/Pathfinding Visualizer/Assets/CodeMonkey/MonoBehaviours/ComponentActions.cs b/Pathfinding Visualizer/Assets/CodeMonkey/MonoBehaviours/ComponentActions.cs new file mode 100644 index 0000000..e0eedc8 --- /dev/null +++ b/Pathfinding Visualizer/Assets/CodeMonkey/MonoBehaviours/ComponentActions.cs @@ -0,0 +1,60 @@ +/* + ------------------- Code Monkey ------------------- + + Thank you for downloading the Code Monkey Utilities + I hope you find them useful in your projects + If you have any questions use the contact form + Cheers! + + unitycodemonkey.com + -------------------------------------------------- + */ + +using System; +using UnityEngine; + +namespace CodeMonkey.MonoBehaviours { + + /* + * Trigger Actions on MonoBehaviour Component events + * */ + public class ComponentActions : MonoBehaviour { + + public Action OnDestroyFunc; + public Action OnEnableFunc; + public Action OnDisableFunc; + public Action OnUpdate; + + private void OnDestroy() { + if (OnDestroyFunc != null) OnDestroyFunc(); + } + + private void OnEnable() { + if (OnEnableFunc != null) OnEnableFunc(); + } + + private void OnDisable() { + if (OnDisableFunc != null) OnDisableFunc(); + } + + private void Update() { + if (OnUpdate != null) OnUpdate(); + } + + + public static void CreateComponent(Action OnDestroyFunc = null, Action OnEnableFunc = null, Action OnDisableFunc = null, Action OnUpdate = null) { + GameObject gameObject = new GameObject("ComponentActions"); + AddComponent(gameObject, OnDestroyFunc, OnEnableFunc, OnDisableFunc, OnUpdate); + } + + public static void AddComponent(GameObject gameObject, Action OnDestroyFunc = null, Action OnEnableFunc = null, Action OnDisableFunc = null, Action OnUpdate = null) { + ComponentActions componentFuncs = gameObject.AddComponent(); + componentFuncs.OnDestroyFunc = OnDestroyFunc; + componentFuncs.OnEnableFunc = OnEnableFunc; + componentFuncs.OnDisableFunc = OnDisableFunc; + componentFuncs.OnUpdate = OnUpdate; + } + + } + +} \ No newline at end of file -- cgit v1.3.1-4-g156e