Utility Scripts
The system has a few very useful utility scripts
- Toolbox : Register and get any object from anywhere using the Toolbox
- Pool Manager : Automatically pools objects to improve performance
- Dsp Time : Get the Dsp Time or the adaptive Dsp Time from anywhere
- Scheduler : Invoke functions after a certain delay
Toolbox
The toolbox can be thought of a master singleton. instead of having many singletons in the system which can easily get out of hand. Having a single centralized singleton which manages all object is much easier to control.
Use this feature with care over relying on it will make your code hard to test outside of play mode.
// Register an object with an ID, by default that ID is 0
Toolbox.Set<MyObjectType>(myObject, objectID);
// Get that object anywhere using the Get function.
var myObject = Toolbox.Get<MyObjectType>(objectID);
Pool Manager
The pool manager automatically pools objects, it allows you to easily create pools of any game object prefab.
// Create a pooled instead of a prefab game object.
var pooledInstance = PoolManager.Instantiate(myPrefab);
// Return the pooled instance to the pool to be reused later.
PoolManager.Destroy(pooledInstance);
DSP Time
Digital Signal Processing time is not constant with the frame time. It can sometimes stay the same for multiple frames. The DSP Time component estimates an adaptive time by taking the last DSP time and adding the delta Time of all the frames where the Internal DSP time did not change. This gives a smoother interpolation when moving objects per frame in sync with the DPS time.
// Get the adaptive time.
var adaptiveDSPTime = DSPTime.AdaptiveTime;
// Get the rea DSP time.
var dspTime = DSPTime.Time;
Scheduler Manager
The scheduler is used to invoke functions delayed in seconds using coroutines.
// Delayed function call
SchedulerManager.Schedule(MyFunction, delay);