generated from vrchat-community/template-package
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: workaround VRCSDK bug where stale data is left in physbone state
Closes: bdunderscore/modular-avatar#845
- Loading branch information
1 parent
5617be4
commit 3126c4f
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#region | ||
|
||
using UnityEngine; | ||
using VRC.SDK3.Dynamics.PhysBone.Components; | ||
using VRC.SDKBase.Editor.BuildPipeline; | ||
|
||
#endregion | ||
|
||
namespace nadena.dev.ndmf.VRChat | ||
{ | ||
/// <summary> | ||
/// When domain reload is disabled, the VRChat physbones gizmo can leave outdated data in the VRCPhysBone component | ||
/// when entering play mode. Force reinitialize the components to work around this issue. | ||
/// | ||
/// Note that we only do this when entering play mode, as this is runtime state, not serialized state. | ||
/// </summary> | ||
public class ForceReinitPhysBonesHook : IVRCSDKPreprocessAvatarCallback | ||
This comment has been minimized.
Sorry, something went wrong. |
||
{ | ||
public int callbackOrder => int.MaxValue; | ||
|
||
public bool OnPreprocessAvatar(GameObject avatarGameObject) | ||
{ | ||
if (Application.isPlaying) | ||
{ | ||
foreach (var physBone in avatarGameObject.GetComponentsInChildren<VRCPhysBone>(true)) | ||
{ | ||
physBone.InitTransforms(true); | ||
physBone.InitParameters(); | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Make internal