I am simply trying to set a texture's filter mode via editor script. Any idea why this isn't working? Any advice is much appreciated! Code (CSharp): Texture2D test = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/test.png", typeof(Texture2D)); test.filterMode = FilterMode.Point;
Don't forget to save the asset and refresh the inspector, might be changing and you just don't see it.
Thank you hpjohn. I have saved using AssetDatabase.SaveAssets(); Still does not work, I can't for the life of me figure this one out. Code (CSharp): using UnityEditor; using UnityEngine; public class TextureProperties { // Add a menu item named "Do Something" to MyMenu in the menu bar. [MenuItem("MyMenu/Do Something")] static void DoSomething() { Texture2D test = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/test.png", typeof(Texture2D)); test.filterMode = FilterMode.Point; AssetDatabase.SaveAssets(); } }
I decided to go with re-importing the texture with new settings, this worked for what I needed. Code (CSharp): TextureImporter importer = (TextureImporter)TextureImporter.GetAtPath("Assets/test.png"); importer.filterMode = FilterMode.Point; importer.textureFormat = TextureImporterFormat.AutomaticTruecolor;
Use: Code (csharp): importer.textureCompression = TextureImporterCompression.Uncompressed; instead of this old method because it is deprecated. Uncompressed mode is the same as old TrueColor.