Skip to content

Instantly share code, notes, and snippets.

@Buravo46
Created January 30, 2014 16:01
Show Gist options
  • Save Buravo46/8711865 to your computer and use it in GitHub Desktop.
Save Buravo46/8711865 to your computer and use it in GitHub Desktop.
【Unity】GUITextureをGUIButtonみたいに扱うことができるスクリプト。参考サイト : http://www.happytrap.jp/blogs/2011/12/26/6382/
using UnityEngine;
using System.Collections;
public class GUITextureButtonScript : MonoBehaviour {
public Texture textureNomal;
public Texture textureHover;
public Texture textureActive;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
// マウスボタンが押された時にコールされる : Active
void OnMouseDown() {
print("MouseDown!");
guiTexture.texture = textureActive;
}
// マウスボタンを離した時にコールされる : Nomal
void OnMouseUp() {
print("MouseUp!");
guiTexture.texture = textureNomal;
}
// マウスカーソルが対象オブジェクトから退出した時にコールされる : Nomal
void OnMouseExit() {
print("MouseExit!");
guiTexture.texture = textureNomal;
}
// マウスカーソルが対象オブジェクトに進入した時にコールされる : Hover
void OnMouseEnter() {
print("MouseEnter!");
guiTexture.texture = textureHover;
}
// マウスカーソルが対象オブジェクトに重なっている間コールされ続ける : Nomal
void OnMouseOver() {
print("MouseOver!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment