2013-07-19 128 views
1

我正在編寫生成資產包的構建實用程序函數。我已經實施了增量式資產建設。我想確保在Unity3d版本中有更新時,我想確保再次構建所有資產包。任何人都可以告訴我如何使用腳本(C#/ Javascript)獲取當前版本的Unity3d。 謝謝獲取當前unity3d版本

回答

5

看來有幾種方法可以做到這一點。

第一種方法是使用preprocessor definition's來檢查您的版本。我不認爲這會是你的問題的解決方案,neverless,你使用它們像這樣:

// Specific version define including the minor revision 
#if UNITY_2_6_0 
// Use Unity 2.6.0 specific feature 
#endif 

// Specific version define not including the minor revision 
#if UNITY_2_6 
// Use Unity 2.6.x specific feature 
#endif 

更有利於你的情況是使用GetFullUnityVersion功能或Application.unityVersion變量。

using UnityEditorInternal; 
... 
DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0, 0); 
Debug.Log(
"Unity version = " + Application.unityVersion + "\n" + 
"Full Unity version = " + InternalEditorUtility.GetFullUnityVersion() + "\n" + 
"Version date = " + dt.AddSeconds(InternalEditorUtility.GetUnityVersionDate())); 

你可以在一個文件中的當前版本保存,每一次,檢查的版本是一樣的。如果不一樣,您將不得不重建資產包。

希望它有幫助!