Last active
December 7, 2015 02:30
-
-
Save tak-km/aabbd725d17dd7ddb0dd to your computer and use it in GitHub Desktop.
選択された時色を変えるタイル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine.EventSystems;// EventSystem利用 | |
public class TileBase : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler,IPointerDownHandler { | |
private Color default_color; // 初期化カラー | |
private Color select_color; // 選択時カラー | |
protected Material _material; | |
void Start () { | |
// このクラスが付属しているマテリアルを取得 | |
_material = this.gameObject.GetComponent<Renderer>().material; | |
// 選択時と非選択時のカラーを保持 | |
default_color = _material.color; | |
select_color = Color.cyan; | |
} | |
//ポインターがオブジェクト上に入った時 | |
public void OnPointerEnter(PointerEventData eventData){ | |
_material.color = select_color; | |
} | |
//ポインターがオブジェクトから出た時 | |
public void OnPointerExit(PointerEventData ped) { | |
_material.color =default_color; | |
} | |
//クリックされた時 | |
public void OnPointerDown(PointerEventData _data){ | |
Debug.Log("clicked"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment