Files
LowPolyRPG/Assets/Plugins/RaycastPro/_Demo/_Scripts/DetectorControl2D.cs
Caleb Sandford deQuincey 715fb68744 Initial commitment
2025-06-25 11:10:11 +01:00

35 lines
994 B
C#

using RaycastPro.Detectors2D;
using UnityEngine;
namespace Plugins.RaycastPro.Demo.Scripts
{
public class DetectorControl2D : MonoBehaviour
{
[SerializeField] private ColliderDetector2D detector;
private void Start()
{
detector.onNewCollider.AddListener(OnNewCollider);
detector.onLostCollider.AddListener(OnLostCollider);
}
private void OnNewCollider(Collider2D col)
{
Debug.Log($"<color=#5AFFDA>{col.name}</color> is Detected.");
if (col.TryGetComponent(out NeonMaterial _neonMaterial))
{
_neonMaterial.SetNeonColor(true);
}
}
private void OnLostCollider(Collider2D col)
{
Debug.Log($"<color=#609EFF>{col.name}</color> is Lost Detect.");
if (col.TryGetComponent(out NeonMaterial _neonMaterial))
{
_neonMaterial.SetNeonColor(false);
}
}
}
}