浏览代码

Added OnUpdate Event + Safety Checks

/main
Thomas ICHÉ 5 年前
当前提交
d5ae6cc1
共有 4 个文件被更改,包括 47 次插入2 次删除
  1. 9
      Runtime/LevelScripting/Events/EventBase.cs
  2. 2
      Runtime/Settings/GameplayIngredientsSettings.cs
  3. 27
      Runtime/LevelScripting/Events/OnUpdateEvent.cs
  4. 11
      Runtime/LevelScripting/Events/OnUpdateEvent.cs.meta

9
Runtime/LevelScripting/Events/EventBase.cs


{
public abstract class EventBase : MonoBehaviour
{
protected bool AllowUpdateCalls()
{
return GameplayIngredientsSettings.currentSettings.allowUpdateCalls;
}
protected bool ForbidUpdateCalls()
{
return !GameplayIngredientsSettings.currentSettings.allowUpdateCalls;
}
}
}

2
Runtime/Settings/GameplayIngredientsSettings.cs


[BoxGroup("Callables")]
[SerializeField, InfoBox("Verbose Calls enable logging at runtime, this can lead to performance drop, use only when debugging.", InfoBoxType.Warning, "m_VerboseCalls")]
private bool m_VerboseCalls = false;
[SerializeField, InfoBox("Per-update calls should be avoided. Enable if strictly necessary.", InfoBoxType.Warning, "m_AllowUpdateCalls")]
[SerializeField, InfoBox("Per-update calls should be avoided due to high performance impact. Enable and use with care, only if strictly necessary.", InfoBoxType.Warning, "m_AllowUpdateCalls")]
private bool m_AllowUpdateCalls = false;
const string kAssetName = "GameplayIngredientsSettings";

27
Runtime/LevelScripting/Events/OnUpdateEvent.cs


using NaughtyAttributes;
namespace GameplayIngredients.Events
{
public class OnUpdateEvent : EventBase
{
[ReorderableList, ShowIf("AllowUpdateCalls"), InfoBox("Update Calls are disabled on this project. Check your GameplayIngredientsSettings asset if you want to allow them.", InfoBoxType.Warning, "ForbidUpdateCalls")]
public Callable[] OnUpdate;
private void OnEnable()
{
}
private void OnDisable()
{
}
private void Update()
{
Callable.Call(OnUpdate, gameObject);
}
}
}

11
Runtime/LevelScripting/Events/OnUpdateEvent.cs.meta


fileFormatVersion: 2
guid: 9a5a3967c24bae54bb6c0fad57a1216c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: bfd8018fed1fdd84ea969e58a0cb01b8, type: 3}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存