(近づくとパネルが出現)
(離れるとパネルが消える)
<スクリプト>
using System.Collections; using System.Collections.Generic; using UnityEngine; public class PanelSwitch : MonoBehaviour { public GameObject target; private float dis; void Update() { dis = Vector3.Distance(transform.position, target.transform.position); if(dis < 30f) { target.SetActive(true); } else { target.SetActive(false); } } }