exdev / ex2d-dev

2D framework and pipeline for Unity3D
ex-dev.com/ex2d
GNU General Public License v3.0
6 stars 3 forks source link

运行时选择exSpriteFont物体抛出异常 #38

Closed xw0 closed 10 years ago

xw0 commented 10 years ago
  1. 运行程序
  2. 动态添加一个包含有exSpriteFont的GameObject
  3. 打开Scene View
  4. 在Hierarchy View里选择刚才创建的GameObject
  5. 无限抛出异常

IndexOutOfRangeException: Array index is out of range. ex2D.Detail.SpriteFontBuilder.BuildText (.exSpriteBase _sprite, ex2D.Detail.SpriteFontParams& sfp, Space _space, .exList1 _vertices, Int32 _vbIndex, .exList1 _uvs) (at Assets/ex2D/Runtime/Components/exSpriteFont.cs:817) exSpriteFont.GetVertices (Space _space) (at Assets/ex2D/Runtime/Components/exSpriteFont.cs:393) exLayeredSprite.GetWorldVertices () (at Assets/ex2D/Runtime/Components/Internal/exLayeredSprite.cs:243) exSpriteBaseInspector.DrawBoundingRect (.exSpriteBase _node, Boolean ignoreZ) (at Assets/ex2D/Editor/Inspector/exSpriteBaseInspector.cs:191) exSpriteBaseInspector.OnSceneGUI () (at Assets/ex2D/Editor/Inspector/exSpriteBaseInspector.cs:181) exSpriteFontInspector.OnSceneGUI () (at Assets/ex2D/Editor/Inspector/exSpriteFontInspector.cs:255) System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Applications/buildAgent/work/84669f285f6a667f/mcs/class/corlib/System.Reflection/MonoMethod.cs:222) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Applications/buildAgent/work/84669f285f6a667f/mcs/class/corlib/System.Reflection/MonoMethod.cs:232) System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Applications/buildAgent/work/84669f285f6a667f/mcs/class/corlib/System.Reflection/MethodBase.cs:115) UnityEditor.SceneView.CallOnSceneGUI () UnityEditor.SceneView.HandleSelectionAndOnSceneGUI () UnityEditor.SceneView.OnGUI () System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Applications/buildAgent/work/84669f285f6a667f/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

jareguo commented 10 years ago

我这边使用beta3及beta4版本进行测试,均未能复现,麻烦你用beta4再测看看。

xw0 commented 10 years ago

update到beta4,问题依然存在。而且以前在游戏里能看到的exSpriteFont现在都看不到了。

当选择exSpriteFont并切换到Scene View时,有一个log和两个error不停的重复显示:

[BuildText|exSpriteFont] i: 12 vbEnd: 24 _vertices: 12 UnityEngine.Debug:Log(Object) ex2D.Detail.SpriteFontBuilder:BuildText(exSpriteBase, SpriteFontParams&, Space, exList1, Int32, exList1) (at Assets/ex2D/Runtime/Components/exSpriteFont.cs:1004) exSpriteFont:GetVertices(Space) (at Assets/ex2D/Runtime/Components/exSpriteFont.cs:436) exLayeredSprite:GetWorldVertices() (at Assets/ex2D/Runtime/Components/Internal/exLayeredSprite.cs:243) exSpriteBaseInspector:DrawBoundingRect(exSpriteBase, Boolean) (at Assets/ex2D/Editor/Inspector/exSpriteBaseInspector.cs:191) exSpriteBaseInspector:OnSceneGUI() (at Assets/ex2D/Editor/Inspector/exSpriteBaseInspector.cs:181) exSpriteFontInspector:OnSceneGUI() (at Assets/ex2D/Editor/Inspector/exSpriteFontInspector.cs:278) UnityEditor.DockArea:OnGUI()

IndexOutOfRangeException: Array index is out of range. ex2D.Detail.SpriteFontBuilder.BuildText (.exSpriteBase _sprite, ex2D.Detail.SpriteFontParams& sfp, Space _space, .exList1 _vertices, Int32 _vbIndex, .exList1 _uvs) (at Assets/ex2D/Runtime/Components/exSpriteFont.cs:1006) exSpriteFont.GetVertices (Space _space) (at Assets/ex2D/Runtime/Components/exSpriteFont.cs:436) exLayeredSprite.GetWorldVertices () (at Assets/ex2D/Runtime/Components/Internal/exLayeredSprite.cs:243) exSpriteBaseInspector.DrawBoundingRect (.exSpriteBase _node, Boolean ignoreZ) (at Assets/ex2D/Editor/Inspector/exSpriteBaseInspector.cs:191) exSpriteBaseInspector.OnSceneGUI () (at Assets/ex2D/Editor/Inspector/exSpriteBaseInspector.cs:181) exSpriteFontInspector.OnSceneGUI () (at Assets/ex2D/Editor/Inspector/exSpriteFontInspector.cs:278) System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Applications/buildAgent/work/84669f285f6a667f/mcs/class/corlib/System.Reflection/MonoMethod.cs:222) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Applications/buildAgent/work/84669f285f6a667f/mcs/class/corlib/System.Reflection/MonoMethod.cs:232) System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Applications/buildAgent/work/84669f285f6a667f/mcs/class/corlib/System.Reflection/MethodBase.cs:115) UnityEditor.SceneView.CallOnSceneGUI () UnityEditor.SceneView.HandleSelectionAndOnSceneGUI () UnityEditor.SceneView.OnGUI () System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Applications/buildAgent/work/84669f285f6a667f/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

The targets array should not be used inside OnSceneGUI or OnPreviewGUI. Use the single target property instead. UnityEditor.DockArea:OnGUI()

以前还有一个很奇怪的和exSpriteFont有关的bug。我用的字体里包括x0123456789十个字符。但是如果用font.text = "x01",这个font显示不出来。但用font.text = "001"又可以。后来的walkaround是先把它设置成001,然后再改成x01,就能显示了。但beta4里好像spritefonts怎么都不显示。感觉这些问题应该都有相关性,就一并说一声了。

jareguo commented 10 years ago

谢了!已经重现并修复了Scene View里面的报错,同时修复了你后面说的显示异常的bug。