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,则视为支持。