Can not set texture filter mode

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!

 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.

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.

TextureImporter importer = (TextureImporter)TextureImporter.GetAtPath("Assets/test.png");
importer.filterMode = FilterMode.Point;
importer.textureFormat = TextureImporterFormat.AutomaticTruecolor;

Use:

importer.textureCompression = TextureImporterCompression.Uncompressed;

instead of this old method because it is deprecated. Uncompressed mode is the same as old TrueColor.