Hi, I'm creating an editor script to generate a gradient texture from a gradient field. I want to set the wrap mode of the newly created texture to clamp. I tried setting the texture.wrapMode before calling Apply(), tried after, tried loading the asset and changing it. Nothing seems to work, the wrap mode always stays to repeat. What am I missing? Thanks! Code (CSharp): Texture2D texture = new Texture2D(width, height, TextureFormat.RGBAFloat, false); for (int x = 0; x < width; x++) { var color = grad.Evaluate((float)x / (float)width); Color[] colors = Enumerable.Repeat(color, height).ToArray(); texture.SetPixels(x, 0, 1, height, colors); } texture.wrapMode = TextureWrapMode.Clamp; // Set the wrap mode texture.Apply();
Maybe try reverse the order of line 12 and 13, in case the .Apply() actually caches some previous values and overwrites the wrap mode... just a thought.
Omg, I forgot to mention the most important! This is a texture that I physically create on the hard drive using this: Code (CSharp): byte[] bytes = texture.EncodeToEXR(Texture2D.EXRFlags.OutputAsFloat); File.WriteAllBytes(savePath, bytes); AssetDatabase.Refresh(); so the import settings remains to repeat and this is what I want to change not using an asset preProcessor if possible.