In this code fragment ...
charInfo.width = (int)ToFloat(charNode, "xadvance");
charInfo.flipped = false;
charInfo.uv = .. a Rect
I get these warnings...
Assets/BitmapFontImporter.cs(54,42): warning CS0618:
UnityEngine.CharacterInfo.width' is obsolete:
CharacterInfo.width is deprecated. Use advance instead.'Assets/BitmapFontImporter.cs(55,42): warning CS0618:
UnityEngine.CharacterInfo.flipped' is obsolete:
CharacterInfo.flipped is deprecated. Use uvBottomLeft, uvBottomRight, uvTopRight or uvTopLeft instead, which will be correct regardless of orientation.'Assets/BitmapFontImporter.cs(63,42): warning CS0618:
UnityEngine.CharacterInfo.uv' is obsolete:
CharacterInfo.uv is deprecated. Use uvBottomLeft, uvBottomRight, uvTopRight or uvTopLeft instead.'Assets/BitmapFontImporter.cs(73,42): warning CS0618:
UnityEngine.CharacterInfo.vert' is obsolete:
CharacterInfo.vert is deprecated. Use minX, maxX, minY, maxY instead.'
BTW this is from the outstanding script: BitmapFontImporter
which is used widely.
Note 3/2016 BitmapFontImporter on git has now been updated per d4Rk's perfect fix below!! Is here: https://github.com/BenoitFreslon/BitmapFontImporter
As the script wasn't working for me at all in Unity 5.3.1, I got rid of all those Warnings (by using the recommended "new" methods)..
After a quick test in the Editor it seems to be working quite well again.
Note: I used the free version of
Glyph Designer
, that's the reason for the watermark on the chars.. But you can see the chars are positioned and sized correctly.
- XmlNode kernings = xml.GetElementsByTagName("kernings")[0];
- charInfo.width = (int)ToFloat (charNode, "xadvance");
- charInfo.flipped = false;
+ charInfo.advance = (int)ToFloat (charNode, "xadvance");
- charInfo.uv = r;
+ charInfo.uvBottomLeft = new Vector2(r.xMin, r.yMin);
+ charInfo.uvBottomRight = new Vector2(r.xMax, r.yMin);
+ charInfo.uvTopLeft = new Vector2(r.xMin, r.yMax);
+ charInfo.uvTopRight = new Vector2(r.xMax, r.yMax);
- charInfo.vert = r;
+ charInfo.minX = (int)r.xMin;
+ charInfo.maxX = (int)r.xMax;
+ charInfo.minY = (int)r.yMax;
+ charInfo.maxY = (int)r.yMin;
See also: https://github.com/BenoitFreslon/BitmapFontImporter/pull/2/commits