示例#1
0
        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}");
            }
        }
示例#2
0
        /*
         * 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}")
                });