[Unity Notes] how to change the compression format of resources corresponding to Texture2D in Unity Editor, and save it, unitytexture2d
There were a lot of pitfalls (almost one afternoon) about storage ). Here is an additional description. If it is only used for the next time, you can use the UnityEditor. compressTexture method to modify the compression format, but this method is restored after the project is re-opened.
To modify the Format of Texture2D, you must modify ImportSettings in Texture2D and the TextureImporterFormat. The Code is as follows:
Texture2D t2D = (Texture2D) AssetDatabase.LoadAssetAtPath(t2D_path, typeof(Texture2D));
TextureImporter ti = (TextureImporter)TextureImporter.GetAtPath(AssetDatabase.GetAssetPath(t2D)); ti.textureFormat = changeTextureImporterFormat;
A t2D object is a read-in Texture2D object. For details about TextureImporterFormat, refer to the official Unity api. The link is as follows:
Http://docs.unity3d.com/ScriptReference/TextureImporterFormat.html
After ImporterFormat is changed, be sure to re-Import Texture2D !! Otherwise, the format conversion cannot be saved. Even if it is correct at the time, the changes will be restored after the project is re-opened. The re-Import method is as follows:
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(t2D));
In this way, the compression format is changed and the project will not be restored after it is re-opened.
I hope to help students in need and try to step on them as little as possible.
How can I use global variables to save the website address of the resource server during Unity3D dynamic loading? It seems that everything I write is wrong. If I write an IP address wrong
The problem details are too messy.
When Unity3D is enabled in Win8, Unity Editor stops working.
The biggest problem with Unity is that it often crashes, but unity engineers are solving it. Unity occupies a large amount of resources.