How to programmatically change image properties?

I’ve written a script that creates a Texture2D from a byte array, using the LoadImage function, which is then used to create a Sprite, using Sprite.create.

The problem is that when this sprite is created, it is automatically set to use a “bilinear filter,” the “pixel to units” is defaulted to 100, and color is set to “compressed,” which is all normally found in the “import settings” of an image, but how can I access these programmatically?

When you got your Texture2D you can access its properties. For example:

Texture2D tex = new Texture2D(100,100);
tex.LoadImage(myByteArray);

tex.filterMode = FilterMode.Bilinear;
tex.anisoLevel = 2;
tex.mipMapBias = -0.5f;
tex.wrapMode = TextureWrapMode.Clamp;

You can see the Texture2D documentation at the following link where you can see which properties can you modify: Texture2D