var iOSGen = iPhone.generation; if (Debug.isDebugBuild) { Debug.Log("iPhone.generation : " + iPhone.generation); Debug.Log("SystemInfo.deviceType : " + SystemInfo.deviceType); Debug.Log("SystemInfo.deviceModel: " + SystemInfo.deviceModel); } if (iOSGen == iPhoneGeneration.iPhone3GS) { SetQualityLevel(2); } else if (iOSGen == iPhoneGeneration.iPhone4) { SetQualityLevel(3); } else if (iOSGen == iPhoneGeneration.iPhone4S) { SetQualityLevel(3); } else if (iOSGen == iPhoneGeneration.iPad1Gen) { SetQualityLevel(2); } else if (iOSGen == iPhoneGeneration.iPad2Gen) { SetQualityLevel(4); } else if (iOSGen == iPhoneGeneration.iPad3Gen) { SetQualityLevel(4); } else if (iOSGen == iPhoneGeneration.iPodTouch3Gen) { SetQualityLevel(3); } else if (iOSGen == iPhoneGeneration.iPodTouch4Gen) { SetQualityLevel(3); } else { if (Debug.isDebugBuild) { Debug.LogWarning("Can‘t detect iOS device type."); } var device : String = SystemInfo.deviceModel; // 调试device :ipad air =iPad4,1iphone 5 =iPhone5,2 所以 下面的判断是错误的 需要做字符串处理
if (device == "iPhone") { if (Debug.isDebugBuild) { Debug.Log("Device type iPhone"); } SetQualityLevel(4); } else if (device == "iPad") { if (Debug.isDebugBuild) { Debug.Log("Device type iPad"); } SetQualityLevel(4); } else if (device == "iPod") { if (Debug.isDebugBuild) { Debug.Log("Device type iPod"); } SetQualityLevel(3); } }
或者:
string id = "";
if (deviceFlag == iPhoneGeneration.iPhone || deviceFlag == iPhoneGeneration.iPhone3G || deviceFlag == iPhoneGeneration.iPhone3GS|| deviceFlag == iPhoneGeneration.iPhone4
|| deviceFlag == iPhoneGeneration.iPhone4S || deviceFlag == iPhoneGeneration.iPhone5 || deviceFlag == iPhoneGeneration.iPhone5C || deviceFlag == iPhoneGeneration.iPhone5S
|| deviceFlag == iPhoneGeneration.iPhoneUnknown || deviceFlag == iPhoneGeneration.Unknown || deviceFlag == iPhoneGeneration.iPodTouch1Gen || deviceFlag ==iPhoneGeneration.iPodTouch2Gen
|| deviceFlag == iPhoneGeneration.iPodTouch3Gen || deviceFlag == iPhoneGeneration.iPodTouch4Gen || deviceFlag == iPhoneGeneration.iPodTouch5Gen || deviceFlag == iPhoneGeneration.iPodTouchUnknown
)
{
id = "0";
}
if (deviceFlag == iPhoneGeneration.iPad1Gen || deviceFlag == iPhoneGeneration.iPad2Gen || deviceFlag == iPhoneGeneration.iPad3Gen || deviceFlag == iPhoneGeneration.iPad4Gen || deviceFlag == iPhoneGeneration.iPadMini1Gen || deviceFlag == iPhoneGeneration.iPadUnknown)
{
id = "1";
}