From 810a1c73681907b2d0774b3ea3636c02fc097efb Mon Sep 17 00:00:00 2001 From: Nunchuk/ToasterOven <49164897+ToastedOven@users.noreply.github.com> Date: Fri, 10 May 2024 14:11:31 -0400 Subject: [PATCH] fix for mode replacement fixes #174 --- CustomEmotesAPI/Core/BoneMapper.cs | 40 +++++++++++++++++++++--------- CustomEmotesAPI/CustomEmotesAPI.cs | 2 +- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/CustomEmotesAPI/Core/BoneMapper.cs b/CustomEmotesAPI/Core/BoneMapper.cs index b16c20e..612172f 100644 --- a/CustomEmotesAPI/Core/BoneMapper.cs +++ b/CustomEmotesAPI/Core/BoneMapper.cs @@ -1398,20 +1398,36 @@ public void LockCameraStuff(bool thirdPersonLock) if (Settings.rootMotionType.Value != RootMotionType.None && (currentClip.lockType == AnimationClipParams.LockType.rootMotion || Settings.rootMotionType.Value == RootMotionType.All || currentClip.lockType == AnimationClipParams.LockType.lockHead)) { - foreach (var item in cameraConstraints) - { - item.ActivateConstraints(); - } + StartCoroutine(ActivateCameraConstraintsAfterFrame(false)); } else if (currentClip.lockType == AnimationClipParams.LockType.headBobbing && Settings.rootMotionType.Value != RootMotionType.None) { - foreach (var item in cameraConstraints) + StartCoroutine(ActivateCameraConstraintsAfterFrame(true)); + } + } + } + IEnumerator ActivateCameraConstraintsAfterFrame(bool onlyY) + { + yield return new WaitForEndOfFrame(); + foreach (var item in cameraConstraints) + { + item.enabled = true; + item.ActivateConstraints(); + if (onlyY && item != cameraConstraints[cameraConstraints.Count - 1]) + { + item.onlyY = true; //activateconstraints turns this off automatically so make sure to do this after we turn them on + } + } + yield return new WaitForEndOfFrame(); + foreach (var item in cameraConstraints) + { + if (!item.enabled) + { + item.enabled = true; + item.ActivateConstraints(); + if (onlyY && item != cameraConstraints[cameraConstraints.Count - 1]) { - item.ActivateConstraints(); - if (item != cameraConstraints[cameraConstraints.Count - 1]) - { - item.onlyY = true; //activateconstraints turns this off automatically so make sure to do this after we turn them on - } + item.onlyY = true; //activateconstraints turns this off automatically so make sure to do this after we turn them on } } } @@ -1435,7 +1451,7 @@ public void TurnOnThirdPerson() needToTurnOffShadows = false; } playerController.thisPlayerModel.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On; - //playerController.thisPlayerModelArms.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly; + playerController.thisPlayerModelArms.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly; if (originalLayer == -1) { originalLayer = playerController.thisPlayerModel.gameObject.layer; @@ -1481,7 +1497,7 @@ public void DeThirdPerson() playerController.thisPlayerModel.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly; } needToTurnOffShadows = true; - //playerController.thisPlayerModelArms.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On; + playerController.thisPlayerModelArms.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; playerController.localVisor.gameObject.SetActive(true); playerController.thisPlayerModel.gameObject.layer = originalLayer; playerController.grabDistance = 3f; diff --git a/CustomEmotesAPI/CustomEmotesAPI.cs b/CustomEmotesAPI/CustomEmotesAPI.cs index 95654a9..8005d4b 100644 --- a/CustomEmotesAPI/CustomEmotesAPI.cs +++ b/CustomEmotesAPI/CustomEmotesAPI.cs @@ -49,7 +49,7 @@ public class CustomEmotesAPI : BaseUnityPlugin public const string PluginName = "Custom Emotes API"; - public const string VERSION = "1.12.2"; + public const string VERSION = "1.12.3"; public struct NameTokenWithSprite { public string nameToken;