TimeAgent implementation adding a generic way to persist custom properties.
This component is made to make things simple, but it should not be used in production if performances are critical.
Because Reflection is used to get custom properties values and it will always be way more slower than direct access.
To get the same result with no performance impact, use TimeAgent UnityEvent or extend TimeAgent with your own class
TimeAgent are the objects managed by the TimeStone.
This class natively handles
Animator data and
To save custom data in the TimeStone, you can either use the
var myTimeAgent = GetComponent(typeOf(TimeAgent));
private void PersistTick(TimeStone stone, TimeStone.TimeTickOrigin origin, float deltaTime)
Or extend the class and override
PersistTick(TimeStone, TimeStone.TimeTickOrigin, float) and
SetDataTick(TimeStone, int). see
GenericTimeAgent for an example.
TimeStone manage its TimeAgents by calling
PersistTick(TimeStone, TimeStone.TimeTickOrigin, float) when data must be
persisted (during record or simulation) and
SetDataTick(TimeStone, int) when data must be updated (during a playback).
ATTENTION : To Execute a simulation, the
TimeStone clones the
TimeAgent, so you must handle that
there are 2 versions of your TimeAgent during a simulation, the Original and the Clone. They can be differentiated using
you can control which will receive callbacks using
During a simulation, the
TimeStone calls the lifeCycle callbacks on its TimeAgents :
SimulationUpdate(float, TimeStone), etc.
To add simulation code execution, you can either use the
onSimulationStart, etc. UnityEvents or extend the class and override