Last active
April 17, 2018 16:22
-
-
Save tsubaki/f3900cb1f7694ede632e52bd2fe31b1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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