UnityEngine.CharacterInfo.width(等)警告
UnityEngine.CharacterInfo.width (etc) warnings
在此代码片段中...
charInfo.width = (int)ToFloat(charNode, "xadvance");
charInfo.flipped = false;
charInfo.uv = .. a Rect
我收到这些警告...
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.'
顺便说一句,这是来自优秀的脚本:BitmapFontImporter
,它被广泛使用。
Note 3/2016 git 上的 BitmapFontImporter 现已根据下面的 d4Rk 完美修复更新!!在这里:https://github.com/BenoitFreslon/BitmapFontImporter
由于脚本在 Unity 5.3.1 中对我来说根本不起作用,我摆脱了所有这些警告(通过使用推荐的 "new" 方法)..
在编辑器中进行快速测试后,它似乎再次运行良好。
注意:我使用的是免费版 Glyph Designer
,这就是字符上出现水印的原因。但是您可以看到字符的位置和大小都正确。
差异如下:
- 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;
另请参阅:
https://github.com/BenoitFreslon/BitmapFontImporter/pull/2/commits
在此代码片段中...
charInfo.width = (int)ToFloat(charNode, "xadvance");
charInfo.flipped = false;
charInfo.uv = .. a Rect
我收到这些警告...
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.'
顺便说一句,这是来自优秀的脚本:BitmapFontImporter
,它被广泛使用。
Note 3/2016 git 上的 BitmapFontImporter 现已根据下面的 d4Rk 完美修复更新!!在这里:https://github.com/BenoitFreslon/BitmapFontImporter
由于脚本在 Unity 5.3.1 中对我来说根本不起作用,我摆脱了所有这些警告(通过使用推荐的 "new" 方法)..
在编辑器中进行快速测试后,它似乎再次运行良好。
Glyph Designer
,这就是字符上出现水印的原因。但是您可以看到字符的位置和大小都正确。
差异如下:
- 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;
另请参阅: https://github.com/BenoitFreslon/BitmapFontImporter/pull/2/commits