Hi, I’m trying to have a button on my screen that will change the texture of my character if the user presses that button. the material with the texture i want to swap is on my gameObject called “joint1”.
I don’t really know what I’m doing… artist trying to do whatever sounds basic in a game-engine…
This is my code at the moment:
var material1 : Material;
function Update () {
for (GUI.Button(Rect(Screen.width - 74,148,64,64)))
{
GameObject.Find("joint1").renderer.sharedMaterial = material1;
}
}
#pragma strict
var myTexture : Texture2D;
private var go : GameObject;
function Start(){
go = GameObject.Find("joint1");
}
function Update () {
if (GUI.Button (Rect (20,40,80,20), "Texture")) {
go.renderer.material.mainTexture = myTexture;
}
}
Here’s the script I came up with eventually. I didn’t know how to swap the textures so… MAJOR THANK YOU!!! I will get to doing it that way tomorrow to save on materials.
I decided to go with a toggle instead of a button.