Unity中SystemInfo中封裝的有個SupportsTextureFormat的方法,直接調用這個方法就可以獲取結果。代碼如下:
public bool ISSupportASTC()
{
bool isSupport = false;
for (TextureFormat i = TextureFormat.ASTC_RGB_4x4; i <= TextureFormat.ASTC_RGBA_12x12; i++)
{
isSupport = SystemInfo.SupportsTextureFormat(i);
if (!isSupport)
return isSupport;
}
return isSupport;
}
根據返回的值,true:支持,false:不支持。
ps:我們遍歷的是左右ASTC格式的,手機只要不支持其中的一個ASTC類型,則視爲不支持,如果所有的ASTC類型都返回的爲true,則視爲支持。