/// <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(); //设置为脏,等待渲染 }
/// <summary> /// Clear references. /// </summary> protected override void OnDisable() { #if UNITY_EDITOR BrandoGraphicRebuildTracker.UnTrackGraphic(this); #endif //从 Canvas 中注销 BrandoUIGraphicRegistry.UnregisterGraphicForCanvas(canvas, this); BrandoCanvasUpdateRegistry.UnRegisterCanvasElementForRebuild(this); if (canvasRenderer != null) { canvasRenderer.Clear(); } LayoutRebuilder.MarkLayoutForRebuild(rectTransform); base.OnDisable(); }