public void AddDisplay(IDebugDisplay a_display) { if (a_display == null) { Debug.LogError("KDebugDisplayHandler:: Attempting to add null display!"); return; } if (_debugDisplayObjects.Count + _activeDisplays.Count == 0) // In the event of no prewarmup, force. { WarmupPool(); } // Pop Object from Pool DebugDisplayObject displayObject = _debugDisplayObjects.Pop(); // Call On Add a_display.OnAdd(displayObject); // Set Parent to Root displayObject.transform.SetParent(_displayRoot.transform); // Turn Culling off - Display now! displayObject.SetShouldCull(false); // Apply Visuals to Display ApplyVisualsToDisplay(a_display); // Add to Active Displays List _activeDisplays.Add(a_display); // Call on Show a_display.OnShow(); }
private void WarmupPool() { // Fill Pool to Max while (_debugDisplayObjects.Count < _maxDisplays) { DebugDisplayObject displayObject = Instantiate(_displayTemplate, _poolRoot.transform); // Cull by Default displayObject.SetShouldCull(true); // Enable Object, Template should be disabled. displayObject.gameObject.SetActive(true); // Push to Pool. _debugDisplayObjects.Push(displayObject); } }
public void RemoveDisplay(IDebugDisplay a_display) { // Cast to Concrete UI Object DebugDisplayObject UIObject = (DebugDisplayObject)a_display.UIObject; // Set to Cull UIObject.SetShouldCull(true); // Parent back under the pool UIObject.Rect.SetParent(_poolRoot.transform); // Remove from the active displays list. _activeDisplays.Remove(a_display); // Call on Remove a_display.OnRemove(); // Push UI Object back into the Pool. _debugDisplayObjects.Push((DebugDisplayObject)a_display.UIObject); }