Skip to content

Latest commit

 

History

History
48 lines (32 loc) · 922 Bytes

README.md

File metadata and controls

48 lines (32 loc) · 922 Bytes

unity-loop-system

Simple and fast Update, FixedUpdate, LateUpdate callbacks alternative, based on PlayerLoop API

Simple usage

Inherit LoopBehaviour and implement IUpdateLoopElement or IFixedUpdateLoopElement or ILateUpdateLoopElement

class Looped : LoopBehaviour, IUpdateLoopElement, IFixedUpdateLoopElement, ILateUpdateLoopElement {
    
    public void OnUpdate() {
        // Update stuff
    }
    
    public void OnFixedUpdate() {
        // FixedUpdate stuff
    }
    
    public void OnLateUpdate() {
        // LateUpdate stuff
    }
    
}

Advanced usage

class Looped : MonoBehaviour {

    private Disposables subscription;

    private void OnEnable() {
        subscription += Loops.Update.Start(OnUpdate);
    }
    
    private void OnDisable() {
        subscription.Dispose();
    }
    
    private void OnUpdate() {
        // Update stuff
    }
}