Hello,
I just started using the GUI system and have a couple of questions.
Earlier I would have done this to create a button:
if (GUI.Button (new Rect (352, 400, 224, 83), characterIcon [characterSelectedOne], "")) {
characterSelectedOne = 0;
}
This created a dynamic texture swap that I like to use.
I want to use this kind of dynamic texture change in the new unity GUI system.
So I created a button called “TeamSpot1” and On Click() it runs a function called
“TeamSpot1”
using UnityEngine;
using System.Collections;
public class ButtonFunctions : MonoBehaviour {
public Texture2D[] characterIcon;
public void TeamSpot1 (){
GameObject _controller = GameObject.Find ("Controller");
Controller controller = _controller.GetComponent<Controller> ();
controller.characterSelectedOne = 0;
}
}
I don’t know if this is a good way to do this, but I would love to have it work in this system.
Suggetions? Ideas. I looked up resource folder etc, but didn’t manage to make it work.