From 198249be1c486fbe24429ad4f19a0880be3cf22c Mon Sep 17 00:00:00 2001 From: Ibodan <-> Date: Wed, 3 Oct 2018 13:44:57 +0900 Subject: [PATCH] Fix issue FirstPersonExclusion does not work as expected --- CustomAvatar/FirstPersonExclusion.cs | 6 +----- CustomAvatar/PlayerAvatarManager.cs | 3 +++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CustomAvatar/FirstPersonExclusion.cs b/CustomAvatar/FirstPersonExclusion.cs index b4a5c66..3bfbe42 100644 --- a/CustomAvatar/FirstPersonExclusion.cs +++ b/CustomAvatar/FirstPersonExclusion.cs @@ -19,17 +19,13 @@ private void OnEnable() } _startLayers = Exclude.Select(x => x.layer).ToArray(); - - Plugin.Instance.FirstPersonEnabledChanged += OnFirstPersonEnabledChanged; - OnFirstPersonEnabledChanged(Plugin.Instance.FirstPersonEnabled); } private void OnDisable() { - Plugin.Instance.FirstPersonEnabledChanged -= OnFirstPersonEnabledChanged; } - private void OnFirstPersonEnabledChanged(bool firstPersonEnabled) + public void OnFirstPersonEnabledChanged(bool firstPersonEnabled) { for (var i = 0; i < Exclude.Length; i++) { diff --git a/CustomAvatar/PlayerAvatarManager.cs b/CustomAvatar/PlayerAvatarManager.cs index 124e784..ab00bbf 100644 --- a/CustomAvatar/PlayerAvatarManager.cs +++ b/CustomAvatar/PlayerAvatarManager.cs @@ -146,6 +146,9 @@ private void OnFirstPersonEnabledChanged(bool firstPersonEnabled) if (_currentSpawnedPlayerAvatar == null) return; AvatarLayers.SetChildrenToLayer(_currentSpawnedPlayerAvatar.GameObject, firstPersonEnabled ? 0 : AvatarLayers.OnlyInThirdPerson); + + foreach (var ex in _currentSpawnedPlayerAvatar.GameObject.GetComponentsInChildren()) + ex.OnFirstPersonEnabledChanged(firstPersonEnabled); } private void SceneManagerOnSceneLoaded(Scene newScene, LoadSceneMode mode)