public static InterfaceType GetInterfaceTypeStatic(IUnityUIAgent agent) { var target = EditorUserBuildSettings.activeBuildTarget; switch (target) { case BuildTarget.iOS: case BuildTarget.Android: return(UnityUI.IsTablet(agent) ? InterfaceType.Tablet : InterfaceType.Phone); case BuildTarget.StandaloneOSX: case BuildTarget.StandaloneWindows: case BuildTarget.StandaloneWindows64: case BuildTarget.StandaloneLinux64: return(InterfaceType.Desktop); case BuildTarget.XboxOne: case BuildTarget.GameCoreXboxOne: case BuildTarget.PS4: case BuildTarget.PS5: case BuildTarget.Switch: return(InterfaceType.Console); case BuildTarget.WebGL: return(InterfaceType.Web); case BuildTarget.tvOS: return(InterfaceType.TV); default: throw new ArgumentOutOfRangeException($"Unknown build type. Target: {target}"); } }
/* * Public. */ public virtual InterfaceType GetInterfaceType() { var platform = Application.platform; var deviceType = SystemInfo.deviceType; switch (platform) { case RuntimePlatform.IPhonePlayer: return(UnityUI.IsTablet(this) ? InterfaceType.Tablet : InterfaceType.Phone); case RuntimePlatform.Android: return(deviceType switch { DeviceType.Handheld => UnityUI.IsTablet(this) ? InterfaceType.Tablet : InterfaceType.Phone, DeviceType.Console => InterfaceType.Console, DeviceType.Desktop => InterfaceType.Desktop, _ => throw new ArgumentOutOfRangeException($"Unknown interface type. Platform: {platform} DeviceType: {deviceType}") });