エディタ上とスマホでタッチ判定をするために以下のスクリプトを書きましたがDebug.Logに何も表示されません。このスクリプトはどこが間違っていますか?スクリプト以外の問題でしょうか?オブジェクトには忘れずにアタッチしました。
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Button : MonoBehaviour { public void Start() { if (Application.isEditor) { if (Input.GetMouseButtonDown(0)) { Debug.Log("クリックした瞬間"); } if (Input.GetMouseButtonUp(0)) { Debug.Log("離した瞬間"); } if (Input.GetMouseButton(0)) { Debug.Log("クリックしっぱなし"); } } else { // タッチされているかチェック if (Input.touchCount > 0) { // タッチ情報の取得 Touch touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Began) { Debug.Log("押した瞬間"); } if (touch.phase == TouchPhase.Ended) { Debug.Log("離した瞬間"); } if (touch.phase == TouchPhase.Moved) { Debug.Log("押しっぱなし"); } } } } }
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/11/11 23:24 編集
2018/11/12 00:53
退会済みユーザー
2018/11/12 09:51