Files
LowPolyRPG/Assets/Plugins/RaycastPro/_Demo/_Scripts/DetectorControl.cs

34 lines
1004 B
C#
Raw Normal View History

2025-06-25 11:10:11 +01:00
using RaycastPro;
using RaycastPro.Detectors;
using UnityEngine;
namespace Plugins.RaycastPro.Demo.Scripts
{
public class DetectorControl : MonoBehaviour
{
[SerializeField] private ColliderDetector detector;
private void Start()
{
detector.onNewCollider.AddListener(OnNewCollider);
detector.onLostCollider.AddListener(OnLostCollider);
}
private void OnNewCollider(Collider col)
{
Debug.Log($"<color=#5AFFDA>{col.name}</color> is Detected.");
if (col.TryGetComponent(out NeonMaterial _neonMaterial))
{
_neonMaterial.SetNeonColor(true);
}
}
private void OnLostCollider(Collider col)
{
Debug.Log($"<color=#609EFF>{col.name}</color> is Lost Detect.");
if (col.TryGetComponent(out NeonMaterial _neonMaterial))
{
_neonMaterial.SetNeonColor(false);
}
}
}
}