Hi,
I know this is an annoying question but I can't find an exhaustive answer on forum.
I want do a script that on touch (mobile Device) change the material of an object.
If it possible I should have a button (or buttons) on gui that when pressed change the material of the object.
If someone have instructions or tutorial this maybe fantastic.
This is the script that i'm trying without succes:
using UnityEngine; using System.Collections; public class SwitchMat : MonoBehaviour { var Sphere : GameObject; var A; var B; // Use this for initialization void Start () { Sphere = GameObject.Find("Sphere"); } // Update is called once per frame void Update () { if (GUI.Button (new Rect(0, 0, 100, 20), "RED")) GameObject.renderer.material = A; if (GUI.Button (new Rect(0, 30, 100, 20), "GREEN")) GameObject.renderer.material = B; } }
Any ideas?
Tank You
Take a look at the VirtualButtonEventHandler in our VirtualButtons sample. That script does exactly what you are attempting, and you can convert it to handle GUI events, rather than VB events.