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 OnLodChangedEvent; protected override void OnLodChanged(int oldLod, int newLod) { base.OnLodChanged(oldLod, newLod); OnLodChangedEvent?.Invoke(oldLod,newLod); } [BIT] private void CalculateBounds() { if(TryGetComponent(out var _collider)) { var bounds1 = _collider.bounds; size = bounds1.size; offset = bounds1.center - transform.position; return; } Bounds bounds = new(); foreach (var x in GetComponentsInChildren()) { 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); } } }