Giter Club home page Giter Club logo

com.lurking-ninja.player-loop's Introduction

com.lurking-ninja.player-loop

A simple helper package to use Unity's custom player loop. The usage is simple:

Installation

You can choose manually installing the package or from GitHub source

Using direct git source code

Use the Package Manager's +/Add package from git URL function. The URL you should use is this:

https://github.com/LurkingNinja/com.lurking-ninja.player-loop.git?path=Packages/com.lurking-ninja.player-loop

Manual install

  1. Download the latest .zip package from the Release section.
  2. Unpack the .zip file into your project's Packages folder.
  3. Open your project and check if it is imported properly.

Usage

using LurkingNinja.PlayerloopManagement;
using UnityEngine;

public class TestPlayerloop : IUpdate
{
    [RuntimeInitializeOnLoadMethod]
    private static void Awake()
    {
        var testPlayerloop = new TestPlayerloop();
        Playerloop.AddListener(testPlayerloop);
    }

    public void OnUpdate() => Debug.Log("Update");
}

You can always use the following type of player-loop entries:

  • EarlyUpdate
  • FixedUpdate
  • PreUpdate
  • Update
  • PreLateUpdate
  • PostLateUpdate

The corresponding interface's name is the same but starts with an "I" as standard, and the callback method starts with the "On" prefix. If you want to register the same class into multiple callbacks use the standard typecasting:

using LurkingNinja.PlayerloopManagement;
using UnityEngine;

public class TestPlayerloop : IUpdate, IPostLateUpdate
{
    [RuntimeInitializeOnLoadMethod]
    private static void Awake()
    {
        var testPlayerloop = new TestPlayerloop();
        Playerloop.AddListener((IUpdate)testPlayerloop);
        Playerloop.AddListener((IPostLateUpdate)testPlayerloop);
    }

    public void OnUpdate() => Debug.Log("Update");
    
    public void OnPostLateUpdate() => Debug.Log("PostLateUpdate");
}

It is possible to keep MonoBehaviour, the Awake or Start method and just register for Update and the rest of the repeated callbacks.

com.lurking-ninja.player-loop's People

Contributors

lurkingninjadev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

com.lurking-ninja.player-loop's Issues

Question : Works in Edit Mode ?

Hello there,

We want to have the same Timeline behaviours in edit mode as in play mode.

Atm we have a script that works in play mode and apply transform tempering on top of timeline animation at LateUpdate (Through a DoTween.Tween set to late update).

The base unity api does not really allow to do anything at Edit time regarding that aspect. (Dotween Edit mode utility bind itself to EditorApplication.Update callback).

Would this package allow me to use LateUpdate at Edit Time ?
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.