示例#1
0
        public override void OnRebuildRequested()
        {
            // After a Font asset gets re-imported the managed side gets deleted and recreated,
            // that means the delegates are not persisted.
            // so we need to properly enforce a consistent state here.
            FontUpdateTracker.UntrackText(this);
            FontUpdateTracker.TrackText(this);

            // Also the textgenerator is no longer valid.
            cachedTextGenerator.Invalidate();

            base.OnRebuildRequested();
        }
示例#2
0
        /// <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();
            }
        }
示例#3
0
 protected override void OnDisable()
 {
     FontUpdateTracker.UntrackText(this);
     base.OnDisable();
 }
示例#4
0
 protected override void OnEnable()
 {
     base.OnEnable();
     cachedTextGenerator.Invalidate();
     FontUpdateTracker.TrackText(this);
 }