/// <summary> /// This method must be called when CanvasRenderer.cull is modified. /// 画布渲染器剔除修改回调 /// </summary> /// <remarks> /// This can be used to perform operations /// that were previously skipped because the <c>Graphic</c> was culled. /// </remarks> public virtual void OnCullingChanged() { if (!canvasRenderer.cull && (m_VertsDirty || m_MaterialDirty)) { /// When we were culled, we potentially skipped calls to <c>Rebuild</c>. BrandoCanvasUpdateRegistry.RegisterCanvasElementForGraphicRebuild(this); } }
/// <summary> /// Mark the material as dirty and needing rebuilt. /// 标记材质为脏,将重建 /// </summary> /// <remarks> /// Send a OnDirtyMaterialCallback notification /// if any elements are registered. See RegisterDirtyMaterialCallback /// </remarks> public virtual void SetMaterialDirty() { if (IsActive()) { m_MaterialDirty = true; BrandoCanvasUpdateRegistry.RegisterCanvasElementForGraphicRebuild(this); m_OnDirtyMaterialCallback?.Invoke(); } }
private static void MarkLayoutRootForRebuild(RectTransform controller) { if (controller == null) { return; } var rebuilder = s_Rebuilders.Get(); rebuilder.Initialize(controller); if (!BrandoCanvasUpdateRegistry.TryRegisterCanvasElementForLayoutRebuild(rebuilder)) { s_Rebuilders.Release(rebuilder); } }
/// <summary> /// Trans外观尺寸变化 /// </summary> protected override void OnRectTransformDimensionsChange() { if (gameObject.activeInHierarchy) { // prevent double dirtying... if (BrandoCanvasUpdateRegistry.IsRebuildingLayout()) { SetVerticesDirty(); } else { SetVerticesDirty(); SetLayoutDirty(); } } }
/// <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(); }
/// <summary> /// 文本纹理更新回调 /// </summary> public void FontTextureChanged() { // Only invoke if we are not destroyed. if (!this) { FontUpdateTracker.UntrackText(this); return; } if (m_DisableFontTextureRebuiltCallback) { return; } //将文本生成器标记为无效。 这将迫使全文生成在下次调用Populate时 cachedTextGenerator.Invalidate(); if (!IsActive()) { return; } // this is a bit hacky, but it is currently the // cleanest solution.... // if we detect the font texture has changed and are in a rebuild loop // we just regenerate the verts for the new UV's //这有点hacky,但它目前是 //最干净的解决方案.... //如果我们检测到字体纹理已更改并且处于重建循环中 //我们只是重新生成新UV的顶点 if (BrandoCanvasUpdateRegistry.IsRebuildingGraphics() || BrandoCanvasUpdateRegistry.IsRebuildingLayout()) { UpdateGeometry(); } else { SetAllDirty(); } }