获取当前的unity3d版本

时间:2013-07-19 09:33:20

标签: unity3d

我正在编写一个生成资产包的构建实用程序函数。我实施了增量资产建设。我想确保在Unity3d版本中有更新时,我想确保再次构建所有资产包。任何人都可以告诉我如何使用脚本(C#/ Javascript)获取当前版本的Unity3d。 感谢

1 个答案:

答案 0 :(得分:6)

似乎有几种方法可以做到这一点。

第一种方法是使用preprocessor definition's来检查您拥有的版本。我不认为这会解决你的问题,永远不会,你这样使用它们:

// 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()));

您可以将当前版本存储在文件中,每次都检查版本是否相同。如果不相同,则必须重建资产包。

希望它有所帮助!