- Home /
How to detect supported texture compression formats?
Hi, I have an asset bundle which contains a bunch of textures, which I have exported using the various Android texture compressions, DXT, PVR etc. Now is there a way to dynamically detect in the main application which method is supported on the device so I can load in the appropriate asset bundle. Or do I have to create different versions of the main application with the different methods hard-coded in?
There's a section in the Android docs which says
Here's an example query for supported texture compression formats from inside a GLSurfaceView.Renderer:
public void onSurfaceChanged(GL10 gl, int w, int h) {
String extensions = gl.glGetString(GL10.GL_EXTENSIONS);
Log.d("ExampleActivity", extensions);
}
This returns a string that lists each of the supported compression formats. Basically any way to get that info in Unity?
Answer by lilinjie_ · Nov 01, 2018 at 01:54 AM
using System;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
public class SupportsTextureFormat : MonoBehaviour {
public Text showText;
void Start () {
StringBuilder sb = new StringBuilder();
CheckSupportsTextureFormats(sb);
showText.text = sb.ToString();
}
void CheckSupportsTextureFormats(StringBuilder sb) {
try {
foreach (TextureFormat format in Enum.GetValues(typeof(TextureFormat))) {
Debug.Log(format.ToString());
// PVRTC_*BPP_* is deprecate. SupportsTextureFormat will throw exception.
if (format.ToString().Contains("PVRTC_2BPP_RGB") || format.ToString().Contains("PVRTC_4BPP_RGB")) {
continue;
}
sb.AppendLine(format.ToString() + ": " + SystemInfo.SupportsTextureFormat(format).ToString());
}
} catch (Exception e) {
Debug.LogError(e.ToString());
}
}
}
I write an example, you can try.
Reference: https://docs.unity3d.com/ScriptReference/SystemInfo.SupportsTextureFormat.html
Your answer
Follow this Question
Related Questions
Mipmapping on Tablets 1 Answer
why cannot build movie texture on android? 4 Answers
Assigning UV Map to model at runtime 0 Answers
Streamreader read .txt file with Android 0 Answers
Saving and loading to/from Android 1 Answer