UnregisterGraphicForCanvas() public static method

Deregister the given Graphic from a Canvas.

public static UnregisterGraphicForCanvas ( Canvas c, Graphic graphic ) : void
c Canvas Canvas.
graphic Graphic Graphic to deregister.
return void
コード例 #1
0
 /// <summary>
 /// 8/6 2020 Graphic源码学习
 /// 在更换父节点之前调用方法
 /// 之所以在更换父节点的情况下进行Canvas的撤销和注册,主要是防止Canvas间切换父节点的情况
 /// </summary>
 protected override void OnBeforeTransformParentChanged()
 {
     // Debug.Log("OnBeforeTransformParentChanged");
     //先撤销组件和canvas的关联
     GraphicRegistry.UnregisterGraphicForCanvas(canvas, this);
     LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
 }
コード例 #2
0
        /// <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);
                }
            }
        }
コード例 #3
0
ファイル: Graphic.cs プロジェクト: jiahaodev/UGUI
 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);
 }
コード例 #4
0
        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);
                }
            }
        }
コード例 #5
0
 protected override void OnBeforeTransformParentChanged()
 {
     if (raycastTarget)
     {
         GraphicRegistry.UnregisterGraphicForCanvas(canvas, this);
     }
     LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
 }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
 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();
 }
コード例 #8
0
ファイル: Graphic.cs プロジェクト: NetherDrk/Eternal-Empire
 /// <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();
 }
コード例 #9
0
ファイル: Graphic.cs プロジェクト: NetherDrk/Eternal-Empire
        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);
        }
コード例 #10
0
        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);
            }
        }
コード例 #11
0
        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();
        }
コード例 #12
0
        /// <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();
        }
コード例 #13
0
        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);
                    }
                }
            }
        }
コード例 #14
0
        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);
            }
        }
コード例 #15
0
        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);
                }
            }
        }
コード例 #16
0
ファイル: Graphic.cs プロジェクト: zlhtech/unity-decompiled
        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);
        }
コード例 #17
0
 protected override void OnBeforeTransformParentChanged()
 {
     GraphicRegistry.UnregisterGraphicForCanvas(this.canvas, this);
     LayoutRebuilder.MarkLayoutForRebuild(this.rectTransform);
 }