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) { BrandoUIGraphicRegistry.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()) { } BrandoUIGraphicRegistry.RegisterGraphicForCanvas(canvas, this); } }
/// <summary> /// 父物体改变 /// </summary> protected override void OnTransformParentChanged() { base.OnTransformParentChanged(); m_Canvas = null; if (!IsActive()) { return; } CacheCanvas(); BrandoUIGraphicRegistry.RegisterGraphicForCanvas(canvas, this); SetAllDirty(); }
/// <summary> /// Mark the Graphic and the canvas as having been changed. /// </summary> protected override void OnEnable() { base.OnEnable(); CacheCanvas(); BrandoUIGraphicRegistry.RegisterGraphicForCanvas(canvas, this); //注册至 Canvas #if UNITY_EDITOR BrandoGraphicRebuildTracker.TrackGraphic(this); #endif if (s_WhiteTexture == null) { s_WhiteTexture = Texture2D.whiteTexture; } SetAllDirty(); //设置为脏,等待渲染 }