Esempio n. 1
0
        /// <summary>
        /// Check if the Unity version is compatible with the version the PlayMaker package was built with.
        /// The Unity build version is stored in UnityBuildVersion by ResetForExport().
        /// ResetForExport is called by build scripts.
        /// </summary>
        public static bool IsUnityVersionCompatible()
        {
            if (string.IsNullOrEmpty(UnityBuildVersion))
            {
                return(true);                                         // no info
            }
            var currentVersionInfo = Application.unityVersion.Split('.');

            if (currentVersionInfo.Length < 2)
            {
                return(true);                               // shouldn't happen
            }
            var buildVersionInfo = UnityBuildVersion.Split('.');

            if (buildVersionInfo.Length < 2)
            {
                return(true);                             // shouldn't happen
            }
            if (int.Parse(currentVersionInfo[0]) < int.Parse(buildVersionInfo[0]))
            {
                return(false);
            }
            if (int.Parse(currentVersionInfo[1]) < int.Parse(buildVersionInfo[1]))
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Check if the Unity version is compatible with the version the PlayMaker package was built with.
        /// The Unity build version is stored in UnityBuildVersion by ResetForExport().
        /// ResetForExport is called by build scripts.
        /// </summary>
        public static bool IsUnityVersionCompatible()
        {
            if (string.IsNullOrEmpty(UnityBuildVersion))
            {
                return(true);                                         // no info
            }
            var currentVersionInfo = Application.unityVersion.Split('.');

            if (currentVersionInfo.Length < 2)
            {
                return(true);                               // shouldn't happen
            }
            var buildVersionInfo = UnityBuildVersion.Split('.');

            if (buildVersionInfo.Length < 2)
            {
                return(true);                             // shouldn't happen
            }
            var currentVersionMajor = int.Parse(currentVersionInfo[0]);
            var currentVersionMinor = int.Parse(currentVersionInfo[1]);
            var buildVersionMajor   = int.Parse(buildVersionInfo[0]);
            var buildVersionMinor   = int.Parse(buildVersionInfo[1]);

            if (currentVersionMajor > buildVersionMajor)
            {
                return(true);
            }
            if (currentVersionMajor == buildVersionMajor)
            {
                return(currentVersionMinor >= buildVersionMinor);
            }

            // currentVersionMajor < buildVersionMajor
            // so not compatible

            return(false);
        }