【小松が手遊び開発を教える】【unity実用スキル】unityのいくつかのトリガイベント
1153 ワード
1.buttonにBox Colliderを掛け、Is Trigger.にチェックを入れる.UIButtonMessageを追加し、TargetとFunctionNameを設定します.
2,.buttonにBox Colliderを掛け、GameObjectにUIEventListenerを掛け、スクリプトを書いてイベントを取得して処理します.
3.buttonにBox Colliderを掛け、GameObject上のスクリプトのUpdate()関数でif(Input.GetMouseButtonDown(0))、if(Input.GetMouseButtonUp(0))を判断する
2,.buttonにBox Colliderを掛け、GameObjectにUIEventListenerを掛け、スクリプトを書いてイベントを取得して処理します.
using UnityEngine;
using System.Collections;
public class PlayerRotateEventHandler : MonoBehaviour {
private GameObject pc_raymond_01;
private bool isPressed = false;
public float scaleRotate = 1.0f;
void Awake()
{
//
}
// Use this for initialization
void Start () {
//pc_raymond_01 = GameObject.Find("UI_3DCharacter/04/pc_dohee");
UIEventListener.Get(gameObject).onDrag = OnCharacterDrag;
UIEventListener.Get(gameObject).onPress = OnCharacterPress;
}
// Update is called once per frame
void Update ()
{
}
void OnCharacterDrag(GameObject obj, Vector2 delta)
{
}
void OnCharacterPress(GameObject obj, bool pressed)
{
isPressed = pressed;
}
}
3.buttonにBox Colliderを掛け、GameObject上のスクリプトのUpdate()関数でif(Input.GetMouseButtonDown(0))、if(Input.GetMouseButtonUp(0))を判断する