Skip to content

Commit

Permalink
dont run OnEnable until injected
Browse files Browse the repository at this point in the history
fixes #5
  • Loading branch information
Aeroluna committed Jan 28, 2025
1 parent 477dd3c commit 51aa925
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Vivify/Controllers/CameraPropertyController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace Vivify.Controllers;
[RequireComponent(typeof(Camera))]
internal class CameraPropertyController : MonoBehaviour
{
private bool _injected;

private Camera _camera = null!;
private DepthTextureMode _cachedDepthTextureMode;
private CameraClearFlags _cachedClearFlags;
Expand Down Expand Up @@ -115,6 +117,11 @@ private void Construct(
SettingsManager settingsManager)
{
_settingsManager = settingsManager;
_injected = true;
if (isActiveAndEnabled)
{
OnEnable();
}
}
#endif

Expand All @@ -132,6 +139,11 @@ private void Awake()

private void OnEnable()
{
if (!_injected)
{
return;
}

_cachedDepthTextureMode = _camera.depthTextureMode;
_cachedClearFlags = _camera.clearFlags;
_cachedBackgroundColor = _camera.backgroundColor;
Expand Down

0 comments on commit 51aa925

Please sign in to comment.