public static bool FirstMajorVersionOfNextCycle(UnityVersion ofMe, out UnityVersion version)
        {
            Ensure.Argument.NotNull(ofMe, nameof(ofMe));

            if (NextCycleNumberOf(ofMe.Cycle, out ushort nextCycle))
            {
                var majorInterval = majorIntervals[nextCycle];
                version = new UnityVersion(nextCycle, majorInterval.Min);
                return(true);
            }

            version = null;
            return(false);
        }
        /// <summary>
        ///     Get the next major version of specified version.
        ///     For example, next major version of Unity-5.4 is Unity-5.5 and next major version of Unity-5.6 is Unity-2017.1.
        /// </summary>
        /// <returns>
        ///     <see langword="true" /> if the next major version successfully fetched; otherwise, <see langword="false" />
        ///     if the specified version is latest major version.
        /// </returns>
        /// <remarks>
        ///     Note that the next version is affected by interval settings field <see cref="majorIntervals" />, it decides whether
        ///     the current instance is latest version, and whether the next version exist.
        /// </remarks>
        public static bool NextMajorVersion(UnityVersion ofMe, out UnityVersion next)
        {
            Ensure.Argument.NotNull(ofMe, nameof(ofMe));

            if (!majorIntervals.TryGetValue(ofMe.Cycle, out var majorInterval))
            {
                return(FirstMajorVersionOfNextCycle(ofMe, out next));
            }

            var nextMajor = (byte)((ofMe.Major ?? 0) + 1);

            if (!majorInterval.Contains(nextMajor))
            {
                return(FirstMajorVersionOfNextCycle(ofMe, out next));
            }

            next = new UnityVersion(ofMe.Cycle, nextMajor);
            return(true);
        }
Ejemplo n.º 3
0
 private static UnityVersion ParseUnityVersion(string version)
 {
     return(string.IsNullOrEmpty(version) ? null : UnityVersion.Parse(version));
 }
Ejemplo n.º 4
0
 public CompatibleUnityVersionAttribute(string minUnityVersion, string maxUnityVersion = null)
 {
     MinUnityVersion = ParseUnityVersion(minUnityVersion);
     MaxUnityVersion = ParseUnityVersion(maxUnityVersion);
 }