protected void OnEnable() { #if !UNITY_EDITOR && UNITY_ANDROID if (!IsAndroidInitialized()) { return; } #endif #if !UNITY_EDITOR && UNITY_IOS //the hook API cannot be automatically called on IOS, so we need try hook it here Hooks.tryHook(); #endif base.OnEnable(); D.assert(_wrapper == null); _configurations = new Configurations(); _wrapper = new UIWidgetsPanelWrapper(); onEnable(); if (fonts != null && fonts.Length > 0) { foreach (var font in fonts) { AddFont(family: font.family, font: font); } } _wrapper.Initiate(this, width: _currentWidth, height: _currentHeight, dpr: _currentDevicePixelRatio, _configurations: _configurations); _configurations.Clear(); texture = _wrapper.renderTexture; Input_OnEnable(); registerPanel(this); }
protected override void OnDisable() { unregisterPanel(this); D.assert(_wrapper != null); _wrapper?.Destroy(); _wrapper = null; texture = null; Input_OnDisable(); base.OnDisable(); }
protected override void OnDisable() { if (_wrapper != null) { unregisterPanel(this); _wrapper.Destroy(); } _wrapper = null; texture = null; Input_OnDisable(); #if !UNITY_EDITOR TryDisableOnDemandGC(); #endif base.OnDisable(); }
protected override void OnEnable() { if (UIWidgetsDisabled) { enabled = false; return; } var type = SystemInfo.graphicsDeviceType; #if !UNITY_EDITOR && UNITY_ANDROID if (type != GraphicsDeviceType.OpenGLES2 && type != GraphicsDeviceType.OpenGLES3) { DisableUIWidgets(); return; } if (!IsAndroidInitialized()) { return; } #endif #if UNITY_IOS || UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX if (type != GraphicsDeviceType.Metal) { DisableUIWidgets(); return; } #endif #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN if (type != GraphicsDeviceType.Direct3D11) { DisableUIWidgets(); return; } #endif // If user duplicates uiwidgets gameobject in scene, canvas could be null during OnEnable, which results in error. Skip to avoid error. // More explanation: during duplication, editor wakes and enables behaviors in certain order. GameObject behaviors are enabled before canvas. if (canvas == null) { enabled = false; startCoroutine(ReEnableUIWidgetsNextFrame()); return; } #if !UNITY_EDITOR && UNITY_IOS //the hook API cannot be automatically called on IOS, so we need try hook it here Hooks.tryHook(); #endif #if !UNITY_EDITOR TryEnableOnDemandGC(); Application.lowMemory += () => { TryDisableOnDemandGC(); GC.Collect(); TryEnableOnDemandGC(); }; #endif base.OnEnable(); D.assert(_wrapper == null); _configurations = new Configurations(); _wrapper = new UIWidgetsPanelWrapper(); onEnable(); if (fonts != null && fonts.Length > 0) { foreach (var font in fonts) { AddFont(family: font.family, font: font); } } _wrapper.Initiate(this, width: _currentWidth, height: _currentHeight, dpr: _currentDevicePixelRatio, _configurations: _configurations); _configurations.Clear(); texture = _wrapper.renderTexture; Input_OnEnable(); registerPanel(this); }