Skip to content

Commit

Permalink
revert some overly-aggressive changes
Browse files Browse the repository at this point in the history
  • Loading branch information
glabute committed Aug 1, 2024
1 parent 88fb6a9 commit 6690b1a
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ public override VisualElement CreateInspectorGUI()
return ux;
}

protected virtual void OnGuiHandler()
protected virtual void OnGuiHandler(CinemachineBrain brain)
{
if (Target == null || !CinemachineCorePrefs.ShowInGameGuides.Value || !Target.isActiveAndEnabled)
return;

var vcam = Target.ComponentOwner;
var brain = CinemachineCore.FindPotentialTargetBrain(vcam);
if (brain == null || !brain.IsLiveChild(vcam) || (brain.OutputCamera.activeTexture != null && CinemachineBrain.ActiveBrainCount > 1))
if (brain == null || brain != CinemachineCore.FindPotentialTargetBrain(vcam)
|| !brain.IsLiveChild(vcam) || (brain.OutputCamera.activeTexture != null && CinemachineBrain.ActiveBrainCount > 1))
return;

var group = vcam.LookAtTargetAsGroup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ protected virtual void OnDisable()
InspectorUtility.RepaintGameView();
}

protected virtual void OnGuiHandler()
protected virtual void OnGuiHandler(CinemachineBrain brain)
{
// Draw the camera guides
if (Target == null || !CinemachineCorePrefs.ShowInGameGuides.Value || !Target.isActiveAndEnabled)
return;

var vcam = Target.VirtualCamera;
var brain = CinemachineCore.FindPotentialTargetBrain(vcam);
if (brain == null || (brain.OutputCamera.activeTexture != null && CinemachineBrain.ActiveBrainCount > 1))
if (brain == null || brain != CinemachineCore.FindPotentialTargetBrain(vcam)
|| (brain.OutputCamera.activeTexture != null && CinemachineBrain.ActiveBrainCount > 1))
return;

bool isLive = targets.Length <= 1 && brain.IsLiveChild(vcam, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ protected virtual void OnDisable()
InspectorUtility.RepaintGameView();
}

protected virtual void OnGuiHandler()
protected virtual void OnGuiHandler(CinemachineBrain brain)
{
if (Target == null || !CinemachineCorePrefs.ShowInGameGuides.Value || !Target.isActiveAndEnabled)
return;

var vcam = Target.VirtualCamera;
var brain = CinemachineCore.FindPotentialTargetBrain(vcam);
if (brain == null || (brain.OutputCamera.activeTexture != null && CinemachineBrain.ActiveBrainCount > 1))
if (brain == null || brain != CinemachineCore.FindPotentialTargetBrain(vcam)
|| (brain.OutputCamera.activeTexture != null && CinemachineBrain.ActiveBrainCount > 1))
return;

// Screen guides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ protected virtual void OnDisable()
InspectorUtility.RepaintGameView();
}

protected virtual void OnGuiHandler()
protected virtual void OnGuiHandler(CinemachineBrain brain)
{
// Draw the camera guides
if (Target == null || !CinemachineCorePrefs.ShowInGameGuides.Value || !Target.isActiveAndEnabled)
return;

var vcam = Target.VirtualCamera;
var brain = CinemachineCore.FindPotentialTargetBrain(vcam);
if (brain == null || (brain.OutputCamera.activeTexture != null && CinemachineBrain.ActiveBrainCount > 1))
if (brain == null || brain != CinemachineCore.FindPotentialTargetBrain(vcam)
|| (brain.OutputCamera.activeTexture != null && CinemachineBrain.ActiveBrainCount > 1))
return;

// Screen guides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public override void OnInspectorGUI()
DrawRemainingPropertiesInInspector();
}

protected virtual void OnGuiHandler()
protected virtual void OnGuiHandler(CinemachineBrain brain)
{
// Draw the camera guides
if (Target == null || !CinemachineCorePrefs.ShowInGameGuides.Value)
Expand All @@ -57,8 +57,8 @@ protected virtual void OnGuiHandler()
return;

var vcam = Target.VirtualCamera;
var brain = CinemachineCore.FindPotentialTargetBrain(vcam);
if (brain == null || (brain.OutputCamera.activeTexture != null && CinemachineBrain.ActiveBrainCount > 1))
if (brain == null || brain != CinemachineCore.FindPotentialTargetBrain(vcam)
|| (brain.OutputCamera.activeTexture != null && CinemachineBrain.ActiveBrainCount > 1))
return;

// Screen guides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public override void OnInspectorGUI()
DrawRemainingPropertiesInInspector();
}

protected virtual void OnGuiHandler()
protected virtual void OnGuiHandler(CinemachineBrain brain)
{
// Draw the camera guides
if (Target == null || !CinemachineCorePrefs.ShowInGameGuides.Value)
Expand All @@ -125,8 +125,8 @@ protected virtual void OnGuiHandler()
return;

var vcam = Target.VirtualCamera;
var brain = CinemachineCore.FindPotentialTargetBrain(vcam);
if (brain == null || (brain.OutputCamera.activeTexture != null && CinemachineBrain.ActiveBrainCount > 1))
if (brain == null || brain != CinemachineCore.FindPotentialTargetBrain(vcam)
|| (brain.OutputCamera.activeTexture != null && CinemachineBrain.ActiveBrainCount > 1))
return;

// Screen guides
Expand Down
4 changes: 2 additions & 2 deletions com.unity.cinemachine/Runtime/Behaviours/CinemachineBrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ void OnPreCull()
}

#if CINEMACHINE_UIELEMENTS
void OnGuiHandler()
void OnGuiHandler(CinemachineBrain brain)
{
if (!ShowDebugText)
if (!ShowDebugText || brain != this)
return;

m_DebugText ??= new DebugText(OutputCamera);
Expand Down
2 changes: 1 addition & 1 deletion com.unity.cinemachine/Runtime/Debug/CinemachineDebug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static void PositionWithinCameraView(VisualElement viewportContainer, Camera cam
/// Delegate for OnGUI debugging.
/// This will be called by the CinemachineDebugDisplay in its OnGUI (editor only)
/// </summary>
public static Action OnGUIHandlers;
public static Action<CinemachineBrain> OnGUIHandlers;

/// <summary>
/// Tracks CinemachineCorePrefs.ShowInGameGuides.Value, so it can be accessed at runtime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
[ExecuteAlways]
class CinemachineDebugDisplay : MonoBehaviour
{
CinemachineBrain m_Brain;

void OnGUI()
{
if (CinemachineDebug.OnGUIHandlers != null && Event.current.type != EventType.Layout)
CinemachineDebug.OnGUIHandlers();
if (m_Brain == null)
TryGetComponent(out m_Brain);
if (m_Brain != null && CinemachineDebug.OnGUIHandlers != null && Event.current.type != EventType.Layout)
CinemachineDebug.OnGUIHandlers(m_Brain);
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ MonoBehaviour:
m_Name: CinemachinePanelSettings
m_EditorClassIdentifier:
themeUss: {fileID: -4733365628477956816, guid: df9aec944f4474a04847b6d6375e4138, type: 3}
m_DisableNoThemeWarning: 0
m_TargetTexture: {fileID: 0}
m_RenderMode: 0
m_WorldSpaceLayer: 0
Expand Down Expand Up @@ -41,4 +42,5 @@ MonoBehaviour:
m_RuntimeShader: {fileID: 9100, guid: 0000000000000000f000000000000000, type: 0}
m_RuntimeWorldShader: {fileID: 9102, guid: 0000000000000000f000000000000000, type: 0}
m_ICUDataAsset: {fileID: 0}
forceGammaRendering: 0
textSettings: {fileID: 0}

0 comments on commit 6690b1a

Please sign in to comment.