How to use ThunderBehaviour
This extension of Monobehaviour is used to bypass unity's magic update methods. For more information on why this is useful, read 1k update calls
ThunderBehaviouris available as a baseclass to use, you can use this instead of your ownMonoBehavioursby doing the following- instead of
void Update()useprotected override void ManagedUpdate() - instead of
void LateUpdate()useprotected override void ManagedLateUpdate() - instead of
void FixedUpdate()useprotected override void ManagedFixedUpdate() - instead of
void OnEnable()useprotected override void ManagedOnEnable() - instead of
void OnDisable()useprotected override void ManagedOnDisable() - Implement
protected override ManagedLoops ManagedLoops => ManagedLoops.Update | ManagedLoops.LateUpdate | ManagedLoops.FixedUpdate- Specify one or more of the
ManagedLoopsenum to indicate to the UpdateManager which loops you want to run on your ThunderBehaviour
- Specify one or more of the
- instead of
Example Classes
using ThunderRoad;
public class ExampleUpdate : ThunderBehaviour
{
//Still use awake as normal
void Awake(){}
//Use the ManagedOnEnable and ManagedOnDisable instead of the unity ones
protected override void ManagedOnEnable() {}
protected override void ManagedOnDisable() {}
//This tells the update manager to only call your ManagedUpdate() function
protected override ManagedLoops ManagedLoops => ManagedLoops.Update;
//This will get called
protected internal override void ManagedUpdate() {}
//Late update is not called because it is not specified in the ManagedLoops
protected internal override void ManagedLateUpdate() {}
}
using ThunderRoad;
public class ExampleFixedAndUpdate : ThunderBehaviour
{
//This tells the update manager to only call your ManagedUpdate() AND ManagedFixedUpdate() functions
protected override ManagedLoops ManagedLoops => ManagedLoops.Update | ManagedLoops.FixedUpdate;
//This will get called
protected internal override void ManagedUpdate() {}
//This will get called
protected internal override void ManagedFixedUpdate() {}
}