Пример #1
0
        public void FontTextureChanged()
        {
            // Only invoke if we are not destroyed.
            if (!this)
            {
                FontUpdateTrackerEx.UntrackText(this);
                return;
            }

            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
            if (CanvasUpdateRegistry.IsRebuildingGraphics() || CanvasUpdateRegistry.IsRebuildingLayout())
            {
                UpdateGeometry();
            }
            else
            {
                SetAllDirty();
            }
        }
Пример #2
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.
            FontUpdateTrackerEx.UntrackText(this);
            FontUpdateTrackerEx.TrackText(this);

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

            base.OnRebuildRequested();
        }
Пример #3
0
        protected override void OnDisable()
        {
            FontUpdateTrackerEx.UntrackText(this);
            base.OnDisable();

            for (int i = 0, count = EmojiConfigList.Count; i < count; ++i)
            {
                var emojiConfig = m_EmojiConfigList[i];
                if (emojiConfig.target != null)
                {
                    emojiConfig.target.Clear();
                    emojiConfig.target.MarkVerticesDirty();
                }
            }

            if (m_UrlRegionList != null)
            {
                m_UrlRegionList.Clear();
            }
        }
Пример #4
0
        // The Text inspector editor can change the font, and we need a way to track changes so that we get the appropriate rebuild callbacks
        // We can intercept changes in OnValidate, and keep track of the previous font reference
        protected override void OnValidate()
        {
            if (m_FontData.font != m_LastTrackedFont)
            {
                Font newFont = m_FontData.font;
                m_FontData.font = m_LastTrackedFont;
                FontUpdateTrackerEx.UntrackText(this);
                m_FontData.font = newFont;
                FontUpdateTrackerEx.TrackText(this);

                m_LastTrackedFont = newFont;
            }
            base.OnValidate();

            if (_mAnimationEmojiPlay != null)
            {
                _mAnimationEmojiPlay.enabled = false;
            }
            cachedTextGenerator.Invalidate();
        }
Пример #5
0
 protected override void OnEnable()
 {
     base.OnEnable();
     cachedTextGenerator.Invalidate();
     FontUpdateTrackerEx.TrackText(this);
 }