public static UnityPlugins CreateTemplate()
        {
            var assemblyReferences = CreateAssemblyReferencesTemplate();

            var managedProjects = new ProjectDict
            {
                ["Full path to your .csproj file."] = new UnityManagedPluginProject
                {
                    Versions = new VersionInfoDict
                    {
                        ["5.6"] = new VersionInfo {
                            AssemblyReferences = assemblyReferences
                        },
                        ["2017.1"] = new VersionInfo {
                            AssemblyReferences = assemblyReferences
                        },
                        ["2017.4"] = new VersionInfo {
                            AssemblyReferences = assemblyReferences
                        }
                    }
                },
                ["Full path to your another .csproj file."] = new UnityManagedPluginProject
                {
                    ForEditor = true
                }
            };

            var fallbackVersions = new VersionInfoDict();
            var ver = HistoricalUnityVersions.Unity_5_3;

            do
            {
                fallbackVersions.Add(ver.ToString(true), new VersionInfo {
                    AssemblyReferences = assemblyReferences
                });
            } while (HistoricalUnityVersions.NextMajorVersion(ver, out ver));

            return(new UnityPlugins
            {
                ManagedProjects = managedProjects,
                DefaultVersions = fallbackVersions
            });
        }
        private static string GetDefineConstantsForUnity(bool isDebug, bool forUnityEditor, UnityVersion version)
        {
            var directives = new List <string> {
                "TRACE"
            };

            if (isDebug)
            {
                directives.Add("DEBUG");
            }
            if (forUnityEditor)
            {
                directives.Add("UNITY_EDITOR");
            }

            if (version != null)
            {
                if (version.Major == null)
                {
                    throw new ArgumentException("Major version number is required.", nameof(version));
                }

                // Unity-5.3 is the minimum unity version that defines X_X_OR_NEWER constants.
                var directiveVer = HistoricalUnityVersions.Unity_5_3;
                while (directiveVer != null && directiveVer <= version)
                {
                    directives.Add($"UNITY_{directiveVer.Cycle}_{directiveVer.Major.Value}_OR_NEWER");
                    if (!HistoricalUnityVersions.NextMajorVersion(directiveVer, out directiveVer))
                    {
                        break;
                    }
                }
                directives.Add($"UNITY_{version.Cycle}_{version.Major}");
                directives.Add($"UNITY_{version.Cycle}");
            }

            return(string.Join(";", directives));
        }
 private static void NextMajorVersion(UnityVersion current, UnityVersion next)
 {
     Assert.IsTrue(HistoricalUnityVersions.NextMajorVersion(current, out var actualNext));
     Assert.AreEqual(next, actualNext);
 }