void Cleanup() { if (m_PanelOwner != null) { InternalBridge.DisposePanel(m_PanelOwner); DestroyImmediate(m_PanelOwner); } panel = null; m_PanelOwner = null; m_PanelScaler = null; }
/// <summary> /// Implementation of OnEnable() /// </summary> public void OnEnable() { m_PanelScaler = GetComponent <PanelScaler>(); m_Event.type = EventType.Repaint; m_Scale = Single.NaN; m_TargetSize = new Vector2(Single.NaN, Single.NaN); m_TargetTexture = targetTexture; InternalBridge.SetTargetTexture(panel, m_TargetTexture); OnValidate(); InternalBridge.RegisterPanel(gameObject.GetInstanceID(), panel); }
void OnEnable() { scaler = GetComponent <PanelScaler>(); }
void Initialize() { if (panel != null && m_PanelOwner == null) { Debug.LogWarning("Unexpected state: panel without owner. Panel will leak."); } if (panel == null || m_PanelOwner == null) { initSampler.Begin(); if (m_PanelOwner == null) { m_PanelOwner = ScriptableObject.CreateInstance <PanelOwner>(); } panel = InternalBridge.CreatePanel(m_PanelOwner); var root = panel.visualTree; root.name = gameObject.name; visualTree = new VisualElement { name = "runtime-panel-container" }; visualTree.style.overflow = Overflow.Hidden; root.Add(visualTree); if (unityStyleSheet != null) { InternalBridge.MarkAsDefaultStyleSheet(unityStyleSheet); root.styleSheets.Add(unityStyleSheet); } if (stylesheets != null) { foreach (var uss in stylesheets) { if (uss != null) { root.styleSheets.Add(uss); } } } initSampler.End(); } if (m_PanelScaler == null) { m_PanelScaler = GetComponent <PanelScaler>(); } m_Event.type = EventType.Repaint; m_Scale = Single.NaN; m_TargetSize = new Vector2(Single.NaN, Single.NaN); if (m_TargetTexture != targetTexture) { m_TargetTexture = targetTexture; InternalBridge.SetTargetTexture(panel, m_TargetTexture); } Validate(); RecreateUIFromUxml(); }