using UnityEngine; namespace Quadtree.Items { /// /// Boundaries of this quadtree item are determined by present UnityEngine.Renderer component. /// [ExecuteInEditMode] [DisallowMultipleComponent] [RequireComponent(typeof(Renderer))] [AddComponentMenu("Spatial partitioning/Quadtree/Items/Renderer-based Item")] public class RendererItem : GameObjectItem { /// /// Determines whether the item should be automatically inserted into the tree upon its initialization. /// /// /// [SerializeField] protected bool InsertOnInitialization = true; private Renderer _renderer; //==========================================================================dd== // Quadtree ITEM METHODS //==========================================================================dd== /// /// Finds and locally stores this GameObject's Renderer component instance. /// protected override void Init() { // load game object renderer component _renderer = GetComponent(); base.Init(); } public override Bounds GetBounds() { return _renderer.bounds; } public override GameObject GetGameObject() => gameObject; } }