Hi
I have a game with a bunch of meshes and before I load them I would like to be able to change the texture (i want one or the other depending on what the user picks on a menu)
I know I can do gameobject.renderer.material.texture=etc
but in this case i don’t have gameobject since i haven’t loaded it into memory yet.
The perfect solution to me would be to be able to change the material. Since every texture has a material, if i were to be able to change the material before the gameobject is created, it would be beautiful.
Can we change the materials without a gameobject? How? I’ve been looking at the web and I only see examples of gameobject.renderer.material…
Regards,
Joaquin
before the object is instantiated, it does not exist and as such you can’t alter it.
also just for clarity: materials have textures, not vice versa. textures on their own, outside of OnGUI and camera target render texture, are totally worthless
but you can change the texture for a material on the editor and that will get applied to every instance and object that uses it on the game.
there is no way to do the same on script before an instance is loaded?
No thats not possible.
Thats because you don’t seem to understand what you do in the editor technical.
The editor does alter the object template in the database, not the object you see actually.
Also if you alter a material, all instances of this material are affected (that holds for both, client and editor).
But what you can not do is alter the object database for stuff you haven’t loaded yet because it does actually not exist at all when in the client.
There really is no problem with Instantiate and assigning a different texture real time with Resource.Load or whatever.