Ejemplo n.º 1
0
 /// <summary>
 ///
 /// <para>
 /// Called by the [FontUpdateTracker] when the texture associated with a font is modified.
 /// </para>
 ///
 /// </summary>
 public void FontTextureChanged()
 {
     if (!(bool)((UnityEngine.Object) this))
     {
         FontUpdateTracker.UntrackText(this);
     }
     else
     {
         if (this.m_DisableFontTextureRebuiltCallback)
         {
             return;
         }
         this.cachedTextGenerator.Invalidate();
         if (!this.IsActive())
         {
             return;
         }
         if (CanvasUpdateRegistry.IsRebuildingGraphics() || CanvasUpdateRegistry.IsRebuildingLayout())
         {
             this.UpdateGeometry();
         }
         else
         {
             this.SetAllDirty();
         }
     }
 }
Ejemplo n.º 2
0
        public void FontTextureChanged()
        {
            // Only invoke if we are not destroyed.
            if (!this)
            {
                FontUpdateTracker.UntrackText(this);
                return;
            }

            if (m_DisableFontTextureChangedCallback)
            {
                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();
            }
        }
Ejemplo n.º 3
0
 public override void OnRebuildRequested()
 {
     FontUpdateTracker.UntrackText(this);
     FontUpdateTracker.TrackText(this);
     this.cachedTextGenerator.Invalidate();
     base.OnRebuildRequested();
 }
Ejemplo n.º 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 (!IsActive())
            {
                base.OnValidate();
                return;
            }

            if (m_FontData.font != m_LastTrackedFont)
            {
                Font newFont = m_FontData.font;
                m_FontData.font = m_LastTrackedFont;

                if (isActiveAndEnabled)
                {
                    FontUpdateTracker.UntrackText(this);
                }

                m_FontData.font = newFont;

                if (isActiveAndEnabled)
                {
                    FontUpdateTracker.TrackText(this);
                }

                m_LastTrackedFont = newFont;
            }
            base.OnValidate();
        }
Ejemplo n.º 5
0
 public void FontTextureChanged()
 {
     if (!this)
     {
         FontUpdateTracker.UntrackText(this);
     }
     else
     {
         if (m_DisableFontTextureRebuiltCallback)
         {
             return;
         }
         cachedTextGenerator.Invalidate();
         if (IsActive())
         {
             if (CanvasUpdateRegistry.IsRebuildingGraphics() || CanvasUpdateRegistry.IsRebuildingLayout())
             {
                 UpdateGeometry();
             }
             else
             {
                 SetAllDirty();
             }
         }
     }
 }
Ejemplo n.º 6
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();
        }
Ejemplo n.º 7
0
 protected override void OnValidate()
 {
     if ((UnityEngine.Object) this.m_FontData.font != (UnityEngine.Object) this.m_LastTrackedFont)
     {
         Font font = this.m_FontData.font;
         this.m_FontData.font = this.m_LastTrackedFont;
         FontUpdateTracker.UntrackText(this);
         this.m_FontData.font = font;
         FontUpdateTracker.TrackText(this);
         this.m_LastTrackedFont = font;
     }
     base.OnValidate();
 }
Ejemplo n.º 8
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;
                FontUpdateTracker.UntrackText(this);
                m_FontData.font = newFont;
                FontUpdateTracker.TrackText(this);

                m_LastTrackedFont = newFont;
            }
            base.OnValidate();
        }
Ejemplo n.º 9
0
 protected override void OnValidate()
 {
     if (!this.IsActive())
     {
         base.OnValidate();
     }
     else
     {
         if (this.m_FontData.font != this.m_LastTrackedFont)
         {
             Font font = this.m_FontData.font;
             this.m_FontData.font = this.m_LastTrackedFont;
             FontUpdateTracker.UntrackText(this);
             this.m_FontData.font = font;
             FontUpdateTracker.TrackText(this);
             this.m_LastTrackedFont = font;
         }
         base.OnValidate();
     }
 }
Ejemplo n.º 10
0
 protected override void OnDisable()
 {
     FontUpdateTracker.UntrackText(this);
     base.OnDisable();
 }
Ejemplo n.º 11
0
 protected override void OnEnable()
 {
     base.OnEnable();
     cachedTextGenerator.Invalidate();
     FontUpdateTracker.TrackText(this);
 }