// UnityExplorer C# console diagnostic — paste into the C# Console tab, hit Run.
// Run once at ultrawide and once at 16:9, then compare.
//
// NOTE: Burglin' Gnomes uses an ORTHOGRAPHIC camera, so fieldOfView is meaningless.
// The governing value is orthographicSize (half the visible world HEIGHT):
//     visible height = 2 * orthographicSize
//     visible width  = visible height * aspect
// If orthographicSize is CONSTANT across resolutions -> already Hor+ (correct).
// If it SHRINKS at wider aspect -> the game holds world-width constant (Vert- lock).
var sb = new System.Text.StringBuilder();

sb.AppendLine($"SCREEN {UnityEngine.Screen.width}x{UnityEngine.Screen.height} " +
    $"aspect={(float)UnityEngine.Screen.width / UnityEngine.Screen.height:F4} " +
    $"full={UnityEngine.Screen.fullScreenMode}");

foreach (var c in UnityEngine.Object.FindObjectsOfType<UnityEngine.Camera>())
{
    if (c.orthographic)
        sb.AppendLine($"CAM  {c.name} ORTHO size={c.orthographicSize:F4} aspect={c.aspect:F4} " +
            $"=> visibleW={2f * c.orthographicSize * c.aspect:F3} visibleH={2f * c.orthographicSize:F3} " +
            $"depth={c.depth} enabled={c.enabled}");
    else
        sb.AppendLine($"CAM  {c.name} PERSP fov={c.fieldOfView:F2} aspect={c.aspect:F4} " +
            $"phys={c.usePhysicalProperties} gate={c.gateFit} depth={c.depth} enabled={c.enabled}");
}

// --- Cinemachine (any version) via reflection: may drive ortho size each frame ---
var bf = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic |
         System.Reflection.BindingFlags.Instance;
foreach (var mb in UnityEngine.Object.FindObjectsOfType<UnityEngine.MonoBehaviour>())
{
    var t = mb.GetType();
    if (t.FullName == null || t.FullName.IndexOf("Cinemachine", System.StringComparison.OrdinalIgnoreCase) < 0)
        continue;
    object lens = null;
    foreach (var name in new[] { "Lens", "m_Lens" })
    {
        var p = t.GetProperty(name, bf); if (p != null) { lens = p.GetValue(mb); break; }
        var f = t.GetField(name, bf);    if (f != null) { lens = f.GetValue(mb); break; }
    }
    if (lens != null)
    {
        var lt = lens.GetType();
        object osize = null, fov = null;
        foreach (var n in new[] { "OrthographicSize", "m_OrthographicSize" })
        { var f = lt.GetField(n, bf); if (f != null) { osize = f.GetValue(lens); break; } }
        foreach (var n in new[] { "FieldOfView", "m_FieldOfView" })
        { var f = lt.GetField(n, bf); if (f != null) { fov = f.GetValue(lens); break; } }
        sb.AppendLine($"CM   {t.Name} '{mb.name}' lensOrthoSize={osize} lensFOV={fov} enabled={mb.enabled}");
    }
    else sb.AppendLine($"CM   {t.Name} '{mb.name}' (no lens) enabled={mb.enabled}");
}

// --- uGUI canvas scalers: match=0 scales by WIDTH (bad at ultrawide), 1 = by HEIGHT ---
foreach (var cs in UnityEngine.Object.FindObjectsOfType<UnityEngine.UI.CanvasScaler>())
    sb.AppendLine($"UI   {cs.name} mode={cs.uiScaleMode} ref={cs.referenceResolution} " +
        $"match={cs.matchWidthOrHeight} screenMatch={cs.screenMatchMode} scaleFactor={cs.scaleFactor}");

UnityExplorer.ExplorerCore.Log(sb.ToString());
