- Home /
Resources.Load texture problem in function Update
If I create an instance in "function Start" and give it a texture like below it works:
function Start () {
var instance : GameObject = Instantiate(Resources.Load("103")) as GameObject;
instance.renderer.material.mainTexture = Resources.Load("entextur");
}
..But if I do the same thing in a "function Update" it doesnt. Like this:
function Update () {
if(Input.GetMouseButtonDown(0) && Input.mousePosition.y < 200){
var instance : GameObject = Instantiate(Resources.Load("103")) as GameObject;
instance.renderer.material.mainTexture = Resources.Load("entextur");
}
}
Why doesnt it work and how do I make it work?
Comment
Best Answer
Answer by Sidar · Jun 12, 2011 at 01:44 PM
Why aren't you just keeping the texture in a variable and load it in the start function, but then use the variable in the update function to assign the material texture?
Your answer
Follow this Question
Related Questions
Assigning UV Map to model at runtime 0 Answers
3d text mesh hides plane object 1 Answer
Problem with texture loading from resources 1 Answer
Objects on minimap replaced with icon? 1 Answer
Texture Offset - bump AND main color 3 Answers