GUIButton.cs 456 B

12345678910111213141516171819202122
  1. using UnityEngine;
  2. using System.Collections;
  3. public class GUIButton : MonoBehaviour {
  4. public Texture textureOut;
  5. public Texture textureOver;
  6. // Use this for initialization
  7. void OnMouseEnter ()
  8. {
  9. if(textureOver != null)
  10. GetComponent<Renderer>().material.mainTexture = textureOver;
  11. }
  12. // Update is called once per frame
  13. void OnMouseExit ()
  14. {
  15. if(textureOut != null)
  16. GetComponent<Renderer>().material.mainTexture = textureOut;
  17. }
  18. }