This repository has been archived on 2026-01-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
AW_2025/Assets/Scripts/SJM/UI_Trigger.cs
2025-02-24 15:18:12 +09:00

45 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UI_Trigger: MonoBehaviour
{
public GameObject uiPanel;
public GameObject Icon;
public float range;
Transform target;
private void Start()
{
target = GameObject.FindWithTag("Player").transform;
InvokeRepeating("UpdateTarget", 0f, 0.25f);
}
private void UpdateTarget()
{
Collider[] cols = Physics.OverlapSphere(transform.position, range, 1<<6);
if (cols.Length > 0)
{
for (int i = 0; i < cols.Length; i++)
{
//print("Collider");
if (cols[i].tag == "Player")
{
//print("Player");
uiPanel.GetComponent<UI>().Active();
Icon.GetComponent<Icon>().Destroy();
}
}
}
else
{
//print("Collider none");
uiPanel.GetComponent<UI>().Destroy();
Icon.GetComponent<Icon>().Active();
}
}
}