- Home /
How do you set a material in c# script?
I would like to know how to set an object's (a cube to be exact) material to a pre-existing material, specifically the grid material? And also, how do you store an image in a variable to modify the texture? I've looked all over and everyone's examples just use a var Texture; but no clue how to get the texture image into that variable. Any help would be appreciated.
Answer by livevlad · Feb 24, 2014 at 12:45 PM
To store an image in a Texture2D, you can use the function : Resources.Load("imagePath",Texture2d);
Here the manual : https://docs.unity3d.com/Documentation/ScriptReference/Resources.Load.html
Hope it helps !
Answer by dakkuuan · Feb 24, 2014 at 01:43 PM
Thanks, found the answer a few hours after I posted this. Thanks for your help.
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to create light like in minecraft? 1 Answer
How to get emissive materials to update and cast light during runtime 1 Answer
Copy collider material on trigger 1 Answer