The following code is an Example how the IResolutionDependency can be used (this example logs whether the screen is in Portrait or Landscape mode):


using TheraBytes.BetterUi;
using UnityEngine;

public class OrientationTracker : MonoBehaviour, IResolutionDependency
{
    // Called by Unity
    private void OnEnable()
    {
        // Check the resolution when the object becomes active
        LogOrientation();
    }

    // Implementation of IResolutionDependency
    public void OnResolutionChanged()
    {
        // Check the resolution after it changed
        LogOrientation();
    }

    // Logs the orientation of the current resolution (Portrait / Landscape)
    private void LogOrientation()
    {
        Vector2 resolution = ResolutionMonitor.CurrentResolution;
        
        if (resolution.x < resolution.y)
        {
            Debug.Log("Portrait");
        }
        else
        {
            Debug.Log("Landscape");
        }
    }
}