unity-atoms/Packages/Core/Runtime/MonoBehaviourHelpers/VariableResetter.cs

24 lines
741 B
C#
Raw Normal View History

2020-03-15 18:18:29 -04:00
using System.Collections.Generic;
using UnityEngine;
namespace UnityAtoms
{
2020-03-21 16:48:05 -04:00
/// <summary>
/// Resets all the Variables in the list on OnEnable. Note that this will cause Events on the Variables to be triggered.
/// </summary>
[AddComponentMenu("Unity Atoms/MonoBehaviour Helpers/Variable Resetter")]
2020-03-15 18:18:29 -04:00
[DefaultExecutionOrder(Runtime.ExecutionOrder.VARIABLE_RESETTER)]
2020-03-17 21:00:18 -04:00
[EditorIcon("atom-icon-delicate")]
2020-03-15 18:18:29 -04:00
public class VariableResetter : MonoBehaviour
{
public List<AtomBaseVariable> _variables = new List<AtomBaseVariable>();
void OnEnable()
{
for (var i = 0; i < _variables.Count; ++i)
{
2020-03-15 19:18:26 -04:00
_variables[i].Reset(true);
2020-03-15 18:18:29 -04:00
}
}
}
}