我正在编写一个生成 Assets 包的构建实用程序函数。我已经实现了 Assets 的增量 build 。我想确保当 Unity3d 版本有更新时,我想确保再次构建所有资源包。谁能告诉我如何使用脚本(C#/Javascript)获取当前版本的 Unity3d。 谢谢
最佳答案
似乎有几种方法可以做到这一点。
第一种方法是使用 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()));
您可以将当前版本存储在一个文件中,并且每次都检查版本是否相同。如果不一样,您将必须重建资源包。
希望对你有帮助!
关于unity-game-engine - 获取当前unity3d版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17742719/