This commit is contained in:
CortexCore
2024-04-16 04:06:46 +08:00
parent 37e7fcea51
commit c798b224be
67 changed files with 1305 additions and 425 deletions

View File

@@ -18,8 +18,17 @@ namespace BITKit.OpenWorld
[SerializeField] private ChunkBehaviour chunkBehaviour;
private void Start()
{
chunkBehaviour.OnLodChangedEvent += OnLodChanged;
if(colliders is {Length:0})colliders = GetComponentsInChildren<Collider>();
try
{
chunkBehaviour.OnLodChangedEvent += OnLodChanged;
if(colliders is {Length:0})colliders = GetComponentsInChildren<Collider>();
}
catch (Exception e)
{
BIT4Log.Warning<ColliderChunkObject>(gameObject.name);
BIT4Log.LogException(e);
}
}
private void OnLodChanged(int arg1, int arg2)
{
@@ -30,22 +39,28 @@ namespace BITKit.OpenWorld
{
x.enabled = enabledCollider;
}
catch (UnassignedReferenceException)
{
GetCollidersInChildren();
OnLodChanged(arg1, arg2);
return;
}
catch (Exception e)
{
BIT4Log.Warning<ColliderChunkObject>(gameObject.name);
BIT4Log.LogException(e);
}
}
}
#if UNITY_EDITOR
[BIT]
private void GetCollidersInChildren()
{
colliders = GetComponentsInChildren<Collider>();
#if UNITY_EDITOR
EditorUtility.SetDirty(this);
#endif
}
#endif
}
}