Skip to content

alexisstrat/unity-player-loop-callbacks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity Player Loop Callbacks

A Unity package that allows hooking pure C# classes to Unity's player loop

Install via manifest

"com.alexandros.unity-player-loop-callbacks": "https://github.com/alexisstrat/unity-player-loop-callbacks.git?path=/Packages/com.alexandros.unity-player-loop-callbacks"

Usage

PlayerLoopCallbacks.Instance.Update += ...
PlayerLoopCallbacks.Instance.FixedUpdate += ...
PlayerLoopCallbacks.Instance.LateUpdate += ...

Example

public class CSharpPlayerLoopSubscriber
{
    public CSharpPlayerLoopSubscriber()
    {
        Subscribe();
    }

    private static void Subscribe()
    {
        PlayerLoopCallbacks.Instance.Update += OnUpdate;
       
        PlayerLoopCallbacks.Instance.FixedUpdate += OnFixedUpdate;
    
        PlayerLoopCallbacks.Instance.LateUpdate += OnLateUpdate;
    }
    
    private static void OnUpdate()
    {
        Debug.Log("Hello Update from C#!");
    }

    private static void OnLateUpdate()
    {
        Debug.Log("Hello LateUpdate from C#!");
    }

    private static void OnFixedUpdate()
    {
        Debug.Log("Hello FixedUpdate from C#!");
    }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages