public List <UnityInstallationInfo> GetPossibleInstallationInfos() { var installations = GetPossibleApplicationPaths(); return(installations.Select(path => { Version version = null; switch (PlatformUtil.RuntimePlatform) { case PlatformUtil.Platform.Windows: version = UnityVersion.ReadUnityVersionFromExe(path); break; case PlatformUtil.Platform.MacOsX: var infoPlistPath = path.Combine("Contents/Info.plist"); version = UnityVersion.GetVersionFromInfoPlist(infoPlistPath); break; case PlatformUtil.Platform.Linux: version = UnityVersion.Parse(path.FullPath); // parse from path break; } return new UnityInstallationInfo(version, path); }).ToList()); }
public UnityApi(UnityVersion unityVersion) { myUnityVersion = unityVersion; myTypes = Lazy.Of(() => { var apiXml = new ApiXml(); return(apiXml.LoadTypes()); }, true); }
public UnityApi(UnityVersion unityVersion) { myUnityVersion = unityVersion; myTypes = Lazy.Of(() => { var apiXml = new ApiXml(); return apiXml.LoadTypes(myUnityVersion.Version); }, true); }
private static List <UnityInstallationInfo> GetPossibleInstallationInfos() { var installations = GetPossibleApplicationPaths(); return(installations.Select(path => { var version = UnityVersion.GetVersionByAppPath(path); return new UnityInstallationInfo(version, path); }).ToList()); }
public UnityApi(UnityVersion unityVersion, KnownTypesCache knownTypesCache) { myUnityVersion = unityVersion; myKnownTypesCache = knownTypesCache; myTypes = Lazy.Of(() => { var apiXml = new ApiXml(); return(apiXml.LoadTypes()); }, true); }
public List <UnityInstallationInfo> GetPossibleInstallationInfos() { var installations = GetPossibleApplicationPaths(); return(installations.Select(a => { var version = UnityVersion.Parse(a.FullPath); if (PlatformUtil.RuntimePlatform == PlatformUtil.Platform.Windows) { version = new Version(new Version(FileVersionInfo.GetVersionInfo(a.FullPath).FileVersion).ToString(3)); } else if (PlatformUtil.RuntimePlatform == PlatformUtil.Platform.MacOsX) { var infoPlistPath = a.Combine("Contents/Info.plist"); var fullVersion = UnityVersion.GetVersionFromInfoPlist(infoPlistPath); version = UnityVersion.Parse(fullVersion); } return new UnityInstallationInfo(version, a); }).ToList()); }
public static UnityInstallationInfo GetApplicationInfo(Version version, UnityVersion unityVersion) { var possible = GetPossibleInstallationInfos().ToArray(); var possibleWithVersion = possible.Where(a => a.Version != null).ToList(); // fast check is we have a best choice var bestChoice = TryGetBestChoice(version, possibleWithVersion); if (bestChoice != null) { return(bestChoice); } // best choice not found by version - try version by path then var pathForSolution = unityVersion.GetActualAppPathForSolution(); var versionByAppPath = UnityVersion.GetVersionByAppPath(pathForSolution); if (versionByAppPath != null) { possibleWithVersion.Add(new UnityInstallationInfo(versionByAppPath, pathForSolution)); } // check best choice again, since newly added version may be best one bestChoice = TryGetBestChoice(version, possibleWithVersion); if (bestChoice != null) { return(bestChoice); } var choice1 = possibleWithVersion.Where(a => a.Version.Major == version.Major && a.Version.Minor == version.Minor && a.Version.Build == version.Build).OrderBy(b => b.Version).LastOrDefault(); if (choice1 != null) { return(choice1); } var choice2 = possibleWithVersion.Where(a => a.Version.Major == version.Major && a.Version.Minor == version.Minor).OrderBy(b => b.Version).LastOrDefault(); if (choice2 != null) { return(choice2); } var choice3 = possibleWithVersion.Where(a => a.Version.Major == version.Major) .OrderBy(b => b.Version).LastOrDefault(); if (choice3 != null) { return(choice3); } var choice4 = possibleWithVersion .OrderBy(b => b.Version).LastOrDefault(); if (choice4 != null) { return(choice4); } var worstChoice = possible.LastOrDefault(); return(worstChoice); }