- Home /
c# Script : Create a texture, then change its parameters
I wrote a script for generating a procedural texture. As directly writing the Texture2D with AssetDatabase.CreateAsset was creating a large file from an unknown format, I encode the texture to PNG and write it to a file. It is then imported automatically by Unity upon refresh and this works well.
Now I would like to set the wrap mode to clamp in the same script, just after the PNG file creation. I tried refreshing with AssetDatabase.Refresh, then getting the texture with LoadMainAssetAtPath, and changing the flag. This does nothing in the project
I also tried using TextureImporter.GetAtPath after having imported the asset in the script, and setting the flag in the importer, without success.
How can I change the wrap mode in the script just after having created the PNG?
Thanks
Answer by IvovdMarel · Jun 27, 2014 at 04:45 PM
By "changing the flag" I meant Texture.wrap$$anonymous$$ode. But this does not make any change in the project as explained.
Ivovd is sorta right, its a pretty trivial affair, without looking I surmise that when you write out the Texture2D to PNG that the original reference stays with the prewritten Texture2D.
This means you now need to grab a reference to the written file and change it that way, or just change the wrap mode before you write it out.
Your answer
Follow this Question
Related Questions
Weapon Switch 1 Answer
Animated Texture Offset 1 Answer
(Solved) Continuous movement 1 Answer
How to assign an image to the Texture class in script 1 Answer