I’m trying to make a GUI button that provides me change the texture of a GameObject… Any ideas?
I tried to use this code, but somehow when I click on button the sphere turns white, no texture…
using UnityEngine;
using System.Collections;
namespace Vuforia
{
public class GUI_Button : MonoBehaviour
{
GameObject Pokeball;
Texture3D texture = (Texture3D) Resources.Load ("Resources/clouds1024");
private void OnGUI()
{
if (GUI.Button (new Rect (5, 15, 100, 25), "Pokebola")) {
Pokeball = GameObject.Find("Pokeball");
Pokeball.GetComponent<Renderer>().material.mainTexture = texture;
}
}
}
}