0
さて、クリックして移動するゲームと、私のプレイヤーが移動したくないパネルがあります。しかし、ユーザーがボタンをクリックしてパネルをアクティブにするまで、パネルは最初は無効になっています。私はcurrentSelectedGameObjectを使ってプレーヤをパネルに向けるのをブロックしましたが、パネルが最初に無効になっていた可能性があります。誰かが私を助けることを願っています。Unity2D:currentSelectedGameObjectパネルが無効にされました
using UnityEngine.EventSystems;
public GameObject currentSelectedGameObject;
public void Update() {
if (Input.GetMouseButtonDown (0)) {
if (EventSystem.current.currentSelectedGameObject)
return;
Vector3 mousePosition = Input.mousePosition;
mousePosition.z = 10; // distance from the camera
target = Camera.main.ScreenToWorldPoint (mousePosition);
target.z = transform.position.z;
}
transform.position = Vector3.MoveTowards (transform.position, target, speed * Time.fixedDeltaTime);
}
ありがとうございます。
if (EventSystem.current.currentSelectedGameObject == currentSelectedGameObject) // now this is your variable that you declared being used in the if statement
は、私の記憶が正しけれカントが、このEventSystemのようにそのをMB::)
提案していただきありがとうございますが、私は実際には動作しませんでした –