Skip to content

Commit

Permalink
Fix issue FirstPersonExclusion does not work as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
Ibodan committed Oct 3, 2018
1 parent c130b51 commit 198249b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 1 addition & 5 deletions CustomAvatar/FirstPersonExclusion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand Down
3 changes: 3 additions & 0 deletions CustomAvatar/PlayerAvatarManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AvatarScriptPack.FirstPersonExclusion>())
ex.OnFirstPersonEnabledChanged(firstPersonEnabled);
}

private void SceneManagerOnSceneLoaded(Scene newScene, LoadSceneMode mode)
Expand Down

0 comments on commit 198249b

Please sign in to comment.