Unity4 升级到 Unity5 更新小记

来源:互联网 发布:c语言 随机模拟 编辑:程序博客网 时间:2024/06/13 05:01

为了某一个Bug,把游戏工程从Unity4.6 升级到Unity5 测试,中间出现了一些问题,小记。


(1) Plugin的使用变化

在Unity5.0中,对于每一个导入的DLL、SO、Jar这些看起来像 Plugin 文件的文件,都会有一个选项设置其作用平台。从Unity4.6 升级到 Unity5.0 的时候,有一些文件不能被正确的判断平台,就会在Platform 选项上设置为 所有 ,就出现了下面的错误。

我们只要找到 对应的文件,然后设置其作用的平台就可以解决这个BUG。


对于DLL,如果这个DLL文件并不是Plugin文件,就取消掉 Platform 的任何勾选。


(2) 废弃了 AddComponent(string) 接口 

从Unity4.6 更新到Unity5.0 ,打开工程后,Unity会自动检测代码并且转换代码到新的API。AddComponent(string) 这个API被转换到下面的样子。

addedComponent = UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(go, "Assets/PlayMaker/Actions/AddComponent.cs (56,21)", component.Value);

在UnityEditor 环境下能正常运行居然,但是在导出Xcode工程时报错:

Assets/PlayMaker/Actions/AddComponent.cs(56,88): error CS0619: `UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(UnityEngine.GameObject, string, string)' is obsolete: `Method is not meant to be used at runtime. Please, replace this call with GameObject.AddComponent<T>()/GameObject.AddComponent(Type).'

意思就是说这个API呗废弃了,现在只能使用 AddComponent(T) 了。

于是修改,先用System.Type.GetType(string) 获取Type,然后在AddComponet 。

但是这样在IL2CPP上可能会有问题,因为IL2CPP是会裁剪代码的,所以可能出现AOT编译问题导致运行时出现类型找不到的BUG。

如果出现这种情况,之前的文章有解决方法:

http://blog.csdn.net/huutu/article/details/43986079





0 0
原创粉丝点击