Unity4 升級到 Unity5 更新小記,unity4unity5

來源:互聯網
上載者:User

Unity4 升級到 Unity5 更新小記,unity4unity5

為了某一個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





聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.