2024-04-16 04:15:06 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using BITKit.OpenWorld;
|
|
|
|
using UnityEngine;
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
using UnityEditor;
|
|
|
|
#endif
|
|
|
|
namespace BITKit.OpenWorld
|
|
|
|
{
|
|
|
|
public class ChunkBehaviour : ChunkObject
|
|
|
|
{
|
|
|
|
public event Action<int,int> OnLodChangedEvent;
|
|
|
|
protected override void OnLodChanged(int oldLod, int newLod)
|
|
|
|
{
|
|
|
|
base.OnLodChanged(oldLod, newLod);
|
|
|
|
OnLodChangedEvent?.Invoke(oldLod,newLod);
|
|
|
|
}
|
2024-04-22 03:48:37 +08:00
|
|
|
#if UNITY_EDITOR
|
2024-04-16 04:15:06 +08:00
|
|
|
[BIT]
|
|
|
|
private void CalculateBounds()
|
|
|
|
{
|
|
|
|
if(TryGetComponent<Collider>(out var _collider))
|
|
|
|
{
|
|
|
|
var bounds1 = _collider.bounds;
|
|
|
|
size = bounds1.size;
|
|
|
|
offset = bounds1.center - transform.position;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Bounds bounds = new();
|
|
|
|
foreach (var x in GetComponentsInChildren<Collider>())
|
|
|
|
{
|
|
|
|
bounds.Encapsulate(x.bounds);
|
|
|
|
if (x.bounds.size.sqrMagnitude > 64)
|
|
|
|
{
|
|
|
|
Debug.LogWarning($"{x.gameObject.name}:Size is too large, please check the size of the collider");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
size = bounds.size;
|
|
|
|
offset = bounds.center - transform.position;
|
|
|
|
EditorUtility.SetDirty(this);
|
|
|
|
}
|
2024-04-22 03:48:37 +08:00
|
|
|
#endif
|
2024-04-16 04:15:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|