Skip to content

Commit

Permalink
Remove CinemachineDebugDisplay
Browse files Browse the repository at this point in the history
  • Loading branch information
glabute committed Aug 6, 2024
1 parent d1706b8 commit 05c41b1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 56 deletions.
46 changes: 16 additions & 30 deletions com.unity.cinemachine/Runtime/Behaviours/CinemachineBrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ public LensModeOverrideSettings LensModeOverride

#if CINEMACHINE_UIELEMENTS && UNITY_EDITOR
DebugText m_DebugText;
CinemachineDebugDisplay m_DebugDisplay;
#endif

void OnValidate()
Expand Down Expand Up @@ -224,8 +223,6 @@ void OnDisable()
CinemachineDebug.OnGUIHandlers -= OnGuiHandler;
m_DebugText?.Dispose();
m_DebugText = null;
if (m_DebugDisplay != null)
m_DebugDisplay.enabled = false;
#endif
s_ActiveBrains.Remove(this);

Expand All @@ -247,33 +244,6 @@ void OnSceneUnloaded(Scene scene)
ManualUpdate();
}

#if UNITY_EDITOR && CINEMACHINE_UIELEMENTS
void Update()
{
if (ShowDebugText || CinemachineDebug.GameViewGuidesEnabled)
{
// Make sure we have a CinemachineDebugDisplay component
if (m_DebugDisplay == null && !TryGetComponent(out m_DebugDisplay))
{
m_DebugDisplay = gameObject.AddComponent<CinemachineDebugDisplay>();
m_DebugDisplay.hideFlags = HideFlags.DontSave | HideFlags.HideInInspector;
}
m_DebugDisplay.enabled = true;
}
else if (m_DebugDisplay != null)
{
// Get rid of the CinemachineDebugDisplay component, so no OnGUI calls are made
RuntimeUtility.DestroyObject(m_DebugDisplay);
m_DebugDisplay = null;
}
if (!ShowDebugText && m_DebugText != null)
{
m_DebugText.Dispose();
m_DebugText = null;
}
}
#endif

void LateUpdate()
{
if (UpdateMethod != UpdateMethods.ManualUpdate)
Expand Down Expand Up @@ -307,8 +277,24 @@ void OnPreCull()
}

#if CINEMACHINE_UIELEMENTS

void OnGUI()
{
if ((ShowDebugText || CinemachineDebug.GameViewGuidesEnabled)
&& CinemachineDebug.OnGUIHandlers != null && Event.current.type != EventType.Layout)
{
CinemachineDebug.OnGUIHandlers(this);
}
}

void OnGuiHandler(CinemachineBrain brain)
{
if (!ShowDebugText && m_DebugText != null)
{
m_DebugText.Dispose();
m_DebugText = null;
}

if (!ShowDebugText || brain != this)
return;

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 @@ -118,7 +118,7 @@ static void PositionWithinCameraView(VisualElement viewportContainer, Camera cam

/// <summary>
/// Delegate for OnGUI debugging.
/// This will be called by the CinemachineDebugDisplay in its OnGUI (editor only)
/// This will be called by the CinemachineDebugBrain in its OnGUI (editor only)
/// </summary>
public static Action<CinemachineBrain> OnGUIHandlers;

Expand Down
23 changes: 0 additions & 23 deletions com.unity.cinemachine/Runtime/Debug/CinemachineDebugDisplay.cs

This file was deleted.

This file was deleted.

0 comments on commit 05c41b1

Please sign in to comment.