Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions com.unity.cinemachine/Runtime/Behaviours/CinemachineBrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.Serialization;

#if CINEMACHINE_HDRP || CINEMACHINE_LWRP_7_3_1
#if CINEMACHINE_HDRP_7_3_1
Expand Down Expand Up @@ -207,8 +206,16 @@ public Camera OutputCamera
public GameObject ControlledObject
{
get => m_TargetOverride == null ? gameObject : m_TargetOverride;
set => m_TargetOverride = value;
set
{
if (!ReferenceEquals(m_TargetOverride, value))
{
m_TargetOverride = value;
ControlledObject.TryGetComponent(out m_OutputCamera); // update output camera when target changes
}
}
}

private GameObject m_TargetOverride = null; // never use directly - use accessor

/// <summary>Event with a CinemachineBrain parameter</summary>
Expand Down Expand Up @@ -299,11 +306,15 @@ void OnSceneUnloaded(Scene scene)
ManualUpdate();
}

private void Start()
void Awake()
{
ControlledObject.TryGetComponent(out m_OutputCamera);
}

void Start()
{
m_LastFrameUpdated = -1;
UpdateVirtualCameras(CinemachineCore.UpdateFilter.Late, -1f);
ControlledObject.TryGetComponent(out m_OutputCamera);
}

private void OnGuiHandler()
Expand Down