Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active April 17, 2018 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/f3900cb1f7694ede632e52bd2fe31b1c to your computer and use it in GitHub Desktop.
Save tsubaki/f3900cb1f7694ede632e52bd2fe31b1c to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEngine.Experimental.LowLevel;
using UnityEngine.Experimental.PlayerLoop;
using System.Collections.Generic;
public class StopPhysicsFixedUpdate
{
static PlayerLoopSystem[] originalPlayerLoop, updatedPlayerLoop;
[RuntimeInitializeOnLoadMethod()]
static void Init()
{
var playerLoop = PlayerLoop.GetDefaultPlayerLoop();
originalPlayerLoop = playerLoop.subSystemList[2].subSystemList; // Update
var subSystem = new List<PlayerLoopSystem>(originalPlayerLoop);
subSystem.RemoveAll(c => c.type == typeof(FixedUpdate.PhysicsFixedUpdate));
updatedPlayerLoop = subSystem.ToArray();
PhysicsOFF();
}
public static void PhysicsOFF()
{
var playerLoop = PlayerLoop.GetDefaultPlayerLoop();
var sub = playerLoop.subSystemList[2];
sub.subSystemList = updatedPlayerLoop;
playerLoop.subSystemList[2] = sub;
PlayerLoop.SetPlayerLoop(playerLoop);
}
public static void PhysicsON()
{
var playerLoop = PlayerLoop.GetDefaultPlayerLoop();
var sub = playerLoop.subSystemList[2];
sub.subSystemList = originalPlayerLoop;
playerLoop.subSystemList[2] = sub;
PlayerLoop.SetPlayerLoop(playerLoop);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment