最近想研究一下uFrame插件,于是從AssetStore下載了最新的uFrame插件。下載后導入到Unity是兩個版本的unitypackage包,分別是uFrame-1.5.1r2和uFrame-1.6.3r1。網上簡單查了一下,說兩個版本差別還是挺大的,新版本不能向前兼容。
一、擋路的狗(Bug)
我最后選擇了最新版本,雙擊后導入,導入完成后,控制臺出現如下錯誤:
一大堆錯誤的詳細信息就不一一列出了,第一個錯誤的詳細信息如下:
Assets/uFrame/MVVM/Framework/Editor/Templates/uFrameTemplates.cs(144,48): error CS0246: The type or namespace name `UGUIExtensions' could not be found. Are you missing a using directive or an assembly reference?
分析了一下,發現是UGUIExtensions這個類因為某個原因沒找到,然后,我直接用VS的全局搜索整個解決方案。最后,發現UGUIBindings.cs這個腳本中的UGUIExtensions類被宏命令屏蔽了,因為我使用的Unity版本是5.3.4f1,而UGUIBindings.cs這個腳本的第一行#if UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
直接不支持5.3.4f1,所以解決辦法就是直接在第一行末尾追加|| UNITY_5_3
。
改完保存編譯后,果然沒錯了。本來以為可以開始好好研究了,然而并非如此。
二、攔路虎(Exception)
當我導入ExampleProject案例工程的unitypackage后,一切正常沒有報錯,接著,我選擇Window -> uFrameDesigner打開uFrame的可視化編輯器后,瘋狂的拋出如下異常:
異常詳細信息如下:
UnityException: Texture 'Header3' is not readable, the texture memory can not be accessed from scripts. You can make the texture readable in the Texture Import Settings.
UnityEngine.Texture2D.GetPixels32 () (at C:/buildslave/unity/build/artifacts/generated/common/runtime/TextureBindings.gen.cs:336)
Invert.Common.TexturesExtensions.CutTextureBottomBorder (UnityEngine.Texture2D texture, Int32 cutSize) (at D:/Invert/uFrameGit/uFrameTools/Invert.Core.GraphDesigner.Unity/ElementDesignerStyles.cs:1998)
Invert.Core.GraphDesigner.Unity.Schemas.UnityNodeStyleSchema.ConstructHeaderImage (Boolean expanded, Color color, System.String iconName) (at D:/Invert/uFrameGit/uFrameTools/Invert.Core.GraphDesigner.Unity/Schemas/UnityNodeStyleSchema.cs:57)
Invert.Core.GraphDesigner.Schemas.impl.NodeStyleSchema.GetHeaderImage (Boolean expanded, Color color, System.String iconName) (at D:/Invert/uFrameGit/uFrameTools/Invert.Core.GraphDesigner/Schemas/impl/NodeStyleSchema.cs:176)
Invert.Core.GraphDesigner.HeaderDrawer.Draw (IPlatformDrawer platform, Single scale) (at D:/Invert/uFrameGit/uFrameTools/Invert.Core.GraphDesigner/Drawers/impl/HeaderDrawer.cs:97)
Invert.Core.GraphDesigner.DiagramNodeDrawer.DrawChildren (IPlatformDrawer platform, Single scale) (at D:/Invert/uFrameGit/uFrameTools/Invert.Core.GraphDesigner/Drawers/impl/DiagramNodeDrawer.cs:356)
Invert.Core.GraphDesigner.DiagramNodeDrawer.Draw (IPlatformDrawer platform, Single scale) (at D:/Invert/uFrameGit/uFrameTools/Invert.Core.GraphDesigner/Drawers/impl/DiagramNodeDrawer.cs:292)
Invert.Core.GraphDesigner.GenericNodeDrawer`2[TData,TViewModel].Draw (IPlatformDrawer platform, Single scale) (at D:/Invert/uFrameGit/uFrameTools/Invert.Core.GraphDesigner/Drawers/impl/DiagramNodeDrawer.cs:64)
Invert.Core.GraphDesigner.DiagramDrawer.Draw (IPlatformDrawer platform, Single scale) (at D:/Invert/uFrameGit/uFrameTools/Invert.Core.GraphDesigner/Drawers/impl/DiagramDrawer.cs:146)
Invert.Core.GraphDesigner.DesignerWindow.DrawDiagram (IPlatformDrawer drawer, Vector2 scrollPosition, Single scale, Rect diagramRect) (at D:/Invert/uFrameGit/uFrameTools/Invert.Core.GraphDesigner/Windows/DesignerWindow.cs:349)
Invert.Core.GraphDesigner.DesignerWindow.Draw (IPlatformDrawer drawer, Single width, Single height, Vector2 scrollPosition, Single scale) (at D:/Invert/uFrameGit/uFrameTools/Invert.Core.GraphDesigner/Windows/DesignerWindow.cs:256)
Invert.Core.GraphDesigner.Unity.ElementsDesigner.OnGUI () (at D:/Invert/uFrameGit/uFrameTools/Invert.Core.GraphDesigner.Unity/ElementsDesigner.cs:256)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
這時,uFrame的編輯器窗口也是卡死狀態。通過分析報錯信息發現,是因為一個名為Header3的圖片為非可讀的,所以報錯了。找到Header3圖片,然后修改圖片格式如下:
修改完后所有的都正常了。正在我得意的以為可以好好開始研究一下案例的時候,現實總是殘酷的。。。
三、死耗子(Error)
當我選擇第一個場景雙擊打開點擊運行后,發現報了如下錯誤:
詳細信息就不貼了,第一個問題很明顯,就是相應的場景沒有添加進Build Settings,反正也不知道場景的添加順序,我就直接把案例工程中的所有場景都添加進Build Settings。然后,重新運行就都正常了。終于可以開開心心的研究uFrame了
uFrame-1.5.1r2導入后也有很多錯誤,不過我懶得研究了。我喜歡用新版的,我是一個喜新厭舊的人。對uFrame-1.5.1r2感興趣的人可以自己研究一下。
如果本文有錯誤之處還請幫忙指出。
本文作者: Sheh偉偉
本文鏈接: http://davidsheh.github.io/2016/12/06/uFrame插件導入報錯/
版權聲明: 本博客所有文章除特別聲明外,均采用 CC BY-NC-SA 3.0 許可協議。轉載請注明出處!