diff options
author | tylermurphy534 <tylermurphy534@gmail.com> | 2022-11-06 15:12:42 -0500 |
---|---|---|
committer | tylermurphy534 <tylermurphy534@gmail.com> | 2022-11-06 15:12:42 -0500 |
commit | eb84bb298d2b95aec7b2ae12cbf25ac64f25379a (patch) | |
tree | efd616a157df06ab661c6d56651853431ac6b08b /VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/FixConstraintUpdateOrder.cs | |
download | unityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.tar.gz unityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.tar.bz2 unityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.zip |
move to self host
Diffstat (limited to 'VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/FixConstraintUpdateOrder.cs')
-rw-r--r-- | VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/FixConstraintUpdateOrder.cs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/FixConstraintUpdateOrder.cs b/VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/FixConstraintUpdateOrder.cs new file mode 100644 index 00000000..6735702b --- /dev/null +++ b/VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/FixConstraintUpdateOrder.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEngine.LowLevel; +using UnityEngine.PlayerLoop; + +namespace VRC.SDKBase.Editor +{ +#if !VRC_CLIENT + public static class FixConstraintUpdateOrder + { + [RuntimeInitializeOnLoadMethod] + private static void ApplyFix() + { + PlayerLoopSystem currentPlayerLoopSystem = PlayerLoop.GetCurrentPlayerLoop(); + + // Search the current PlayerLoopSystem's sub-systems for the PreLateUpdate system. + PlayerLoopSystem[] playerLoopSystems = currentPlayerLoopSystem.subSystemList; + int preLateUpdateSystemIndex = Array.FindIndex(playerLoopSystems, system => system.type == typeof(PreLateUpdate)); + PlayerLoopSystem preLateUpdateSystem = playerLoopSystems[preLateUpdateSystemIndex]; + + // Search the PreLateUpdate system's sub-systems for ScriptRunBehaviourLateUpdate and ConstraintManagerUpdate. + List<PlayerLoopSystem> preLateUpdateSystemSubSystems = preLateUpdateSystem.subSystemList.ToList(); + PlayerLoopSystem scriptRunBehaviourLateUpdateSystem = preLateUpdateSystemSubSystems.Find(system => system.type == typeof(PreLateUpdate.ScriptRunBehaviourLateUpdate)); + PlayerLoopSystem constraintManagerUpdateSystem = preLateUpdateSystemSubSystems.Find(system => system.type == typeof(PreLateUpdate.ConstraintManagerUpdate)); + + // Move ScriptRunBehaviourLateUpdate to before ConstraintManagerUpdate. + preLateUpdateSystemSubSystems.Remove(scriptRunBehaviourLateUpdateSystem); + preLateUpdateSystemSubSystems.Insert(preLateUpdateSystemSubSystems.IndexOf(constraintManagerUpdateSystem), scriptRunBehaviourLateUpdateSystem); + + // Update the PlayerLoopSystem structs. + preLateUpdateSystem.subSystemList = preLateUpdateSystemSubSystems.ToArray(); + playerLoopSystems[preLateUpdateSystemIndex] = preLateUpdateSystem; + currentPlayerLoopSystem.subSystemList = playerLoopSystems; + PlayerLoop.SetPlayerLoop(currentPlayerLoopSystem); + } + } +#endif +} |