public static UnregisterGraphicForCanvas ( Canvas c, |
||
c | Canvas | Canvas. |
graphic | Graphic to deregister. | |
return | void |
/// <summary> /// 8/6 2020 Graphic源码学习 /// 在更换父节点之前调用方法 /// 之所以在更换父节点的情况下进行Canvas的撤销和注册,主要是防止Canvas间切换父节点的情况 /// </summary> protected override void OnBeforeTransformParentChanged() { // Debug.Log("OnBeforeTransformParentChanged"); //先撤销组件和canvas的关联 GraphicRegistry.UnregisterGraphicForCanvas(canvas, this); LayoutRebuilder.MarkLayoutForRebuild(rectTransform); }
/// <summary> /// 17/6 2020 Graphic学习 /// 主要是Canvas显示隐藏或者canvas控件OnEnable、Disable的时候调用 /// 主要是检测Canvas控件的 /// </summary> protected override void OnCanvasHierarchyChanged() { // Debug.Log("OnCanvasHierarchyChanged"); // Use m_Cavas so we dont auto call CacheCanvas Canvas currentCanvas = m_Canvas; // Clear the cached canvas. Will be fetched below if active. m_Canvas = null; if (!IsActive()) { return; } CacheCanvas(); if (currentCanvas != m_Canvas) { //currentCanvas != m_Canvas时,说明UI更换了canvas,需要与之前的Canvas解除关联 GraphicRegistry.UnregisterGraphicForCanvas(currentCanvas, this); // Only register if we are active and enabled as OnCanvasHierarchyChanged can get called // during object destruction and we dont want to register ourself and then become null. if (IsActive()) { //如果当前组件还是在激活状态下的话,就将当前UI和新的canvas进行注册绑定 GraphicRegistry.RegisterGraphicForCanvas(canvas, this); } } }
protected override void OnBeforeTransformParentChanged() { //Deregister the given Graphic from a Canvas. GraphicRegistry.UnregisterGraphicForCanvas(canvas, this); //Mark the given RectTransform as needing it's layout to be recalculated during the next layout pass. LayoutRebuilder.MarkLayoutForRebuild(rectTransform); }
protected override void OnCanvasHierarchyChanged() { // Use m_Cavas so we dont auto call CacheCanvas Canvas currentCanvas = m_Canvas; // Clear the cached canvas. Will be fetched below if active. m_Canvas = null; if (!IsActive()) { return; } CacheCanvas(); if (currentCanvas != m_Canvas) { GraphicRegistry.UnregisterGraphicForCanvas(currentCanvas, this); // Only register if we are active and enabled as OnCanvasHierarchyChanged can get called // during object destruction and we dont want to register ourself and then become null. if (IsActive()) { GraphicRegistry.RegisterGraphicForCanvas(canvas, this); } } }
protected override void OnBeforeTransformParentChanged() { if (raycastTarget) { GraphicRegistry.UnregisterGraphicForCanvas(canvas, this); } LayoutRebuilder.MarkLayoutForRebuild(rectTransform); }
protected override void OnCanvasHierarchyChanged() { Canvas c = this.m_Canvas; this.CacheCanvas(); if (c != this.m_Canvas) { GraphicRegistry.UnregisterGraphicForCanvas(c, this); GraphicRegistry.RegisterGraphicForCanvas(this.canvas, this); } }
protected override void OnDisable() { GraphicRegistry.UnregisterGraphicForCanvas(this.canvas, this); CanvasUpdateRegistry.UnRegisterCanvasElementForRebuild(this); if (this.canvasRenderer != null) { this.canvasRenderer.Clear(); } LayoutRebuilder.MarkLayoutForRebuild(this.rectTransform); base.OnDisable(); }
/// <summary> /// /// <para> /// See MonoBehaviour.OnDisable. /// </para> /// /// </summary> protected override void OnDisable() { GraphicRebuildTracker.UnTrackGraphic(this); GraphicRegistry.UnregisterGraphicForCanvas(this.canvas, this); CanvasUpdateRegistry.UnRegisterCanvasElementForRebuild((ICanvasElement)this); if ((UnityEngine.Object) this.canvasRenderer != (UnityEngine.Object)null) { this.canvasRenderer.Clear(); } LayoutRebuilder.MarkLayoutForRebuild(this.rectTransform); base.OnDisable(); }
protected override void OnCanvasHierarchyChanged() { Canvas c = this.m_Canvas; this.CacheCanvas(); if (!((UnityEngine.Object)c != (UnityEngine.Object) this.m_Canvas)) { return; } GraphicRegistry.UnregisterGraphicForCanvas(c, this); GraphicRegistry.RegisterGraphicForCanvas(this.canvas, this); }
protected override void OnCanvasHierarchyChanged() { // Use m_Cavas so we dont auto call CacheCanvas Canvas currentCanvas = m_Canvas; CacheCanvas(); if (currentCanvas != m_Canvas) { GraphicRegistry.UnregisterGraphicForCanvas(currentCanvas, this); GraphicRegistry.RegisterGraphicForCanvas(canvas, this); } }
protected override void OnDestroy() { #if UNITY_EDITOR GraphicRebuildTracker.UnTrackGraphic(this); #endif GraphicRegistry.UnregisterGraphicForCanvas(canvas, this); CanvasUpdateRegistry.UnRegisterCanvasElementForRebuild(this); if (m_CachedMesh) { Destroy(m_CachedMesh); } m_CachedMesh = null; base.OnDestroy(); }
/// <summary> /// Clear references. /// </summary> protected override void OnDisable() { #if UNITY_EDITOR GraphicRebuildTracker.UnTrackGraphic(this); #endif GraphicRegistry.UnregisterGraphicForCanvas(canvas, this); CanvasUpdateRegistry.UnRegisterCanvasElementForRebuild(this); if (canvasRenderer != null) { canvasRenderer.Clear(); } LayoutRebuilder.MarkLayoutForRebuild(rectTransform); base.OnDisable(); }
protected override void OnCanvasHierarchyChanged() { Canvas canvas = this.m_Canvas; this.m_Canvas = null; if (this.IsActive()) { this.CacheCanvas(); if (canvas != this.m_Canvas) { GraphicRegistry.UnregisterGraphicForCanvas(canvas, this); if (this.IsActive()) { GraphicRegistry.RegisterGraphicForCanvas(this.canvas, this); } } } }
protected override void OnCanvasHierarchyChanged() { // Use m_Cavas so we dont auto call CacheCanvas Canvas currentCanvas = m_Canvas; // Clear the cached canvas. Will be fetched below if active. m_Canvas = null; if (!IsActive()) { return; } CacheCanvas(); if (currentCanvas != m_Canvas) { GraphicRegistry.UnregisterGraphicForCanvas(currentCanvas, this); GraphicRegistry.RegisterGraphicForCanvas(canvas, this); } }
protected override void OnCanvasHierarchyChanged() { Canvas currentCanvas = m_Canvas; m_Canvas = null; if (!IsActive()) { return; } CacheCanvas(); if (currentCanvas != m_Canvas) { GraphicRegistry.UnregisterGraphicForCanvas(currentCanvas, this); if (IsActive()) { GraphicRegistry.RegisterGraphicForCanvas(canvas, this); } } }
protected override void OnCanvasHierarchyChanged() { Canvas canvas = this.m_Canvas; this.m_Canvas = (Canvas)null; if (!this.IsActive()) { return; } this.CacheCanvas(); if (!((UnityEngine.Object)canvas != (UnityEngine.Object) this.m_Canvas)) { return; } GraphicRegistry.UnregisterGraphicForCanvas(canvas, this); if (!this.IsActive()) { return; } GraphicRegistry.RegisterGraphicForCanvas(this.canvas, this); }
protected override void OnBeforeTransformParentChanged() { GraphicRegistry.UnregisterGraphicForCanvas(this.canvas, this); LayoutRebuilder.MarkLayoutForRebuild(this.rectTransform); }