Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Pasty on September 11, 2014, 02:53:48 PM

Title: Dynamic Fonts in Flash
Post by: Pasty on September 11, 2014, 02:53:48 PM
It seems that dynamic fonts are working in Flash player builds in Unity 4.5.3. Are there any plans to add support for this with NGUI?
Title: Re: Dynamic Fonts in Flash
Post by: ArenMook on September 12, 2014, 04:05:04 AM
It's just a simple matter of changing a few #ifs. I'll see about doing that for the next update.
Title: Re: Dynamic Fonts in Flash
Post by: Pasty on September 15, 2014, 02:41:57 PM
I looked into it myself and did the following:

removed #if !UNITY_FLASH wherever it preceded #define DYNAMIC_FONT (7 files)
UIFont.cs - replaced fontNames[] usage (No support in UnityEngine)
UILabel.cs - replaced use of '++usage' with sepeate line for incrementing
UILabel.cs - created custom LastIndexOfAny() and IndexOfAny() methods to replace incompatible ones
UIWidget.cs - switched to if (!(mOnRender == value)) since Flash doesn't support .Equals()

Seems OK now!
Title: Re: Dynamic Fonts in Flash
Post by: sluice on September 16, 2014, 02:08:53 PM
Also, had this issue. You both pointed me in the right direction but I still had to fiddle around...
Here's how to fix it, more precisly:  :D


1. In: NGUIText.cs, UILabel.cs & UIFont.cs
Change:
  1. #if !UNITY_3_5 && !UNITY_FLASH
  2. #define DYNAMIC_FONT
  3. #endif
to:
  1. #if !UNITY_3_5
  2. #define DYNAMIC_FONT
  3. #endif


2. In UILabel.cs
Change:
  1. mFontUsage[mActiveTTF] = ++usage;
to
  1. mFontUsage[mActiveTTF] = usage+1;


3. Lastly, in UIFont.cs
Change:
  1. #if DYNAMIC_FONT
  2.                 if (a.isDynamic && b.isDynamic && a.dynamicFont.fontNames[0] == b.dynamicFont.fontNames[0]) return true;
  3. #endif
to
  1. #if DYNAMIC_FONT && !UNITY_FLASH
  2.                 if (a.isDynamic && b.isDynamic && a.dynamicFont.fontNames[0] == b.dynamicFont.fontNames[0]) return true;
  3. #endif


4. VoilĂ ! You may need to re-import the NGUI folder (from the project view) by right-clicking and selecting re-import
Title: Re: Dynamic Fonts in Flash
Post by: ArenMook on September 17, 2014, 11:53:07 AM
Thanks!