public static RegisterGraphicForCanvas ( Canvas c, |
||
c | Canvas | Canvas to register. |
graphic | Graphic to register. | |
return | void |
/// <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 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 OnTransformParentChanged() { if (this.IsActive()) { this.CacheCanvas(); GraphicRegistry.RegisterGraphicForCanvas(this.canvas, this); this.SetAllDirty(); } }
protected override void OnTransformParentChanged() { base.OnTransformParentChanged(); if (IsActive()) { CacheCanvas(); GraphicRegistry.RegisterGraphicForCanvas(canvas, this); SetAllDirty(); } }
/// <summary> /// Mark the Graphic and the canvas as having been changed. /// </summary> protected override void OnEnable() { base.OnEnable(); CacheCanvas(); GraphicRegistry.RegisterGraphicForCanvas(canvas, this); #if UNITY_EDITOR GraphicRebuildTracker.TrackGraphic(this); #endif SetAllDirty(); }
protected override void OnEnable() { base.OnEnable(); this.CacheCanvas(); GraphicRegistry.RegisterGraphicForCanvas(this.canvas, this); if (Graphic.s_WhiteTexture == null) { Graphic.s_WhiteTexture = Texture2D.whiteTexture; } this.SetAllDirty(); }
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 OnTransformParentChanged() { base.OnTransformParentChanged(); this.m_Canvas = (Canvas)null; if (!this.IsActive()) { return; } this.CacheCanvas(); GraphicRegistry.RegisterGraphicForCanvas(this.canvas, this); this.SetAllDirty(); }
protected override void OnEnable() { base.OnEnable(); this.CacheCanvas(); GraphicRegistry.RegisterGraphicForCanvas(this.canvas, this); GraphicRebuildTracker.TrackGraphic(this); if ((UnityEngine.Object)Graphic.s_WhiteTexture == (UnityEngine.Object)null) { Graphic.s_WhiteTexture = Texture2D.whiteTexture; } this.SetAllDirty(); }
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); } }
/// <summary> /// Mark the Graphic and the canvas as having been changed. /// </summary> protected override void OnEnable() { base.OnEnable(); CacheCanvas(); GraphicRegistry.RegisterGraphicForCanvas(canvas, this); #if UNITY_EDITOR GraphicRebuildTracker.TrackGraphic(this); #endif if (s_WhiteTexture == null) { s_WhiteTexture = Texture2D.whiteTexture; } SetAllDirty(); }
protected override void OnTransformParentChanged() { base.OnTransformParentChanged(); m_Canvas = null; if (!IsActive()) { return; } CacheCanvas(); GraphicRegistry.RegisterGraphicForCanvas(canvas, this); //全部重建(布局、材质、顶点) SetAllDirty(); }
protected override void OnTransformParentChanged() { base.OnTransformParentChanged(); m_Canvas = null; if (!IsActive()) { return; } CacheCanvas(); if (raycastTarget) { GraphicRegistry.RegisterGraphicForCanvas(canvas, this); } SetAllDirty(); }
/// <summary> /// 16/6 2020 Graphic源码学习 /// 在更换父节点时调用方法 /// </summary> protected override void OnTransformParentChanged() { // Debug.Log(" OnTransformParentChanged"); base.OnTransformParentChanged(); m_Canvas = null; if (!IsActive()) { return; } //查找这个物体的canvas CacheCanvas(); //将canvas和图形组件进行绑定 GraphicRegistry.RegisterGraphicForCanvas(canvas, this); SetAllDirty(); }
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); }