1
This commit is contained in:
@@ -5,7 +5,6 @@ using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Pool;
|
||||
using System.Linq;
|
||||
using UnityEditor.Search;
|
||||
|
||||
namespace BITKit.Sensors
|
||||
{
|
||||
@@ -19,6 +18,8 @@ namespace BITKit.Sensors
|
||||
[SerializeField] private bool autoUpdate;
|
||||
[SerializeField]private float radius;
|
||||
private readonly CacheList<Transform> cache = new();
|
||||
private readonly CacheList<AudioSensorService.AudioSensorData> data = new();
|
||||
public AudioSensorService.AudioSensorData[] Noises => data.ValueArray;
|
||||
private void OnEnable()
|
||||
{
|
||||
Id = GetInstanceID();
|
||||
@@ -32,14 +33,19 @@ namespace BITKit.Sensors
|
||||
{
|
||||
var position = transform.position;
|
||||
cache.Clear();
|
||||
data.Clear();
|
||||
foreach (var x in AudioSensorService.QuadtreeRoot.Find(new Bounds(position, Vector3.one * radius)))
|
||||
{
|
||||
var distance = Vector3.Distance(position, x.Position);
|
||||
if(distance>radius) continue;
|
||||
cache.Add(x.Transform);
|
||||
var distance = Vector3.Distance(position, x.Position);
|
||||
if (distance > radius) continue;
|
||||
if (x.Transform)
|
||||
cache.Add(x.Transform);
|
||||
data.Add(x);
|
||||
}
|
||||
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
public HashSet<int> Ignores { get; } = new();
|
||||
public int Id { get; set; }
|
||||
public IEnumerable<Transform> Get() => cache.ValueArray;
|
||||
public bool IsValid(Collider _collider) => false;
|
||||
|
Reference in New Issue
Block a user