Instantly share code, notes, and snippets.

Embed
What would you like to do?
using UnityEngine;
using UnityEngine.Experimental.LowLevel;
using UnityEngine.Experimental.PlayerLoop;
using System.Collections.Generic;
public class PreUpdateSystem
{
[RuntimeInitializeOnLoadMethod()]
static void Init()
{
var mySystem = new PlayerLoopSystem()
{
type = typeof(MyLoopSystemUpdate),
updateDelegate = () =>
{
Debug.Log("DO IT!!!");
}
};
var playerLoop = PlayerLoop.GetDefaultPlayerLoop();
var updateSystem = playerLoop.subSystemList[4]; // Update
var subSystem = new List<PlayerLoopSystem>(updateSystem.subSystemList);
subSystem.Insert(0, mySystem);
updateSystem.subSystemList = subSystem.ToArray();
playerLoop.subSystemList[4] = updateSystem;
PlayerLoop.SetPlayerLoop(playerLoop);
}
public struct MyLoopSystemUpdate{ }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment