- Home /
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?
Answer by dsada · Jul 16, 2014 at 07:56 AM
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
I looked through that documentation a thousand times and couldn't find it for the life of me, but now I see them... Thanks!
its much easier to google your needs than search through the documentation :)