OnCullingChanged(bool)
Called when the state's culling state changes.
Read time 1 minuteLast updated 13 days ago
Definition
- Type: Method
- Namespace: Unity.GraphToolkit.Editor
- Assembly: UnityEditor
public virtual void OnCullingChanged(bool cullingEnabled)
Parameters
truefalseRemarks
States are culled when they are off-screen or too small to render at the current zoom level. When the state returns from being culled ( is ), the contents of IStateView.Root have been cleared and the built-in parts have been rebuilt. Re-add any custom UI you allocated in StateView<T>.OnViewBuilt.
cullingEnabledfalseCache references to your custom elements in fields so this callback can re-parent them via without allocating new ones.
View.Root.Add(...)When the state is being culled ( is ), you typically don't need to do anything; use this branch only if you need to release resources for culled states.
cullingEnabledtrueExamples
Label m_Label; // Allocated in OnViewBuilt.public override void OnCullingChanged(bool cullingEnabled){ if (!cullingEnabled && m_Label != null) { // Root was cleared while culled — re-parent the cached label. View.Root.Add(m_Label); }}