public override void OnRebuildRequested() { FontUpdateTracker.UntrackText(this); FontUpdateTracker.TrackText(this); this.cachedTextGenerator.Invalidate(); base.OnRebuildRequested(); }
/// <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(); } } }
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(); } } } }
public void FontTextureChanged() { // Only invoke if we are not destroyed. if (!this) { FontUpdateTracker.UntrackText(this); return; } if (m_DisableFontTextureRebuiltCallback) { 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(); } }
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(); }
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(); }
// 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(); }
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(); } }
protected override void OnDisable() { FontUpdateTracker.UntrackText(this); base.OnDisable(); }