Else load next texture.

Hi, I am able to successfully load an image onto an object by using this code..

function OnMouseUp () {
renderer.material.mainTexture = Resources.Load("image1");
}

I click on the object and the image appears from the Resources folder. What I am wanting to do is load a different image, the next in a sequence. (image2, image3, image4 etc). How would I go about the code to check and load.. like

else if material.mainTexture = Resources.Load("image1") then
renderer.material.mainTexture = Resources.Load("image2");
}

1 Answer

1
var imageNum = 1;
var maxImageNum = 3;

function OnMouseUp()
{
  renderer.material.mainTexture = Resources.Load("image"+imageNum);
  imageNum++;
  if (imageNum == maxImageNum)
    imageNum = 1;
}

fixed thanks. If this is your answer, please hit the checkmark there to the left to accept it

–

^This would require a custom IK solution, though. What I did was use the HeadlookController script with the whole upper body. Looks goods! :)

–