5f9e8f979d
cell values and grid lines are displayed. no interaction available yet.
60 lines
1.9 KiB
C#
60 lines
1.9 KiB
C#
/*
|
|
------------------- 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<ComponentActions>();
|
|
componentFuncs.OnDestroyFunc = OnDestroyFunc;
|
|
componentFuncs.OnEnableFunc = OnEnableFunc;
|
|
componentFuncs.OnDisableFunc = OnDisableFunc;
|
|
componentFuncs.OnUpdate = OnUpdate;
|
|
}
|
|
|
|
}
|
|
|
|
} |