- Home /
Preview procedural texture in scene without serializing it?
I am generating textures procedurally using a script. I have some fields that it's useful to be able to tweak using the editor and then preview the result in context in the scene view.
Currently, I use OnValidate
to regenerate textures and assign them to the Material
of the corresponding MeshRenderer
. This makes the texture show up in the scene view.
It seems that MeshRenderer
serializes its Material
, which in turn serializes my texture.
However, my scripts takes the DPI into account when generating this texture, so the result is device-dependent. As a result, I'm storing and deserializing extra data each time my game loads to then just throw it away and replace it.
Is there a better solution where I can preview my textures in the Scene view when composing my scene without needlessly serializing, storing, and deserializing it?
Answer by drudiverse · Mar 15, 2016 at 10:12 AM
I worked alot with procedural textures. i didnt use onvalidate particularly if i recall. you can write them to .bmp and load to renderer... you dont have to preview it in scene view if you want to just see the texture, you can save it as a bmp and even there is a command to open it in chrome or paint usis .exe... so you can see using tab back and forth between unity, it will auto open a tab of a pic viewer for you. for shadows and lighting you have to load it as texture.
I did alot of GPU generated texture wich is muuuuch faster than cpu for live games and so on but you can only save cpu gen textures as textures easily, you have to save gpy textres as saved data.
theres a lot of info about procedural textures around on unify wiki and other sources, use google images to search unity procedural textures, actually goog images is better than goog search for searchign visual techniques or syntax methods within unity.
The thing is, I DO want to preview it in the scene. For example, if I'm generating a background I want to be able to see what my scene will actually look like without having to hit play.
Your answer
Follow this Question
Related Questions
How to assign object reference to ObjectField knowing the object's name? 2 Answers
Custom inspector variable resets automatically 1 Answer
Dynamic serialized fields based on enum 0 Answers
Storing data about an asset only in the editor 2 Answers
Help with Missing Monobehaviours and Asset Serialization? 0 Answers