public static void Launch(LaunchOptions options) { Logger.Verbose = options.Verbose; var unityProject = new UnityProject(options.ProjectPath); Logger.Info("Attempting to launch Unity with project '{0}'", options.ProjectPath); if (!unityProject.IsValid()) { Logger.Error("The passed project doesn't seem like a valid Unity project."); Environment.ExitCode = 1; return; } var unityHub = new UnityHub(options.HubPath); if (!unityHub.PathExists()) { Logger.Error("Unity hub was not found"); Environment.ExitCode = 1; return; } var unityInstall = unityHub.GetInstall(unityProject.UnityVersion); if (unityInstall == null) { if (!options.InstallIfNeeded) { Logger.Error("Unity version '{0}' doesn't seem to be installed", unityProject.UnityVersion); Logger.Info("You can use the '--install-if-needed' option to automatically install it"); Environment.ExitCode = 1; return; } Logger.Info("Unity version is not yet installed, doing that next"); if (!InstallVersion(unityHub, unityProject.UnityVersion, unityProject.UnityVersionChangeset)) { Logger.Error("Failed to install, not opening project"); Environment.ExitCode = 1; return; } unityInstall = unityHub.GetInstall(unityProject.UnityVersion); } var unityArgs = new UnityLaunchArguments(unityProject); options.CopyTo(unityArgs); if (options.Headless) { unityArgs.SetHeadless(); } var exitCode = unityInstall.Launch(unityArgs); Environment.ExitCode = exitCode; }
public static void Install(InstallOptions options) { Logger.Verbose = options.Verbose; var unityHub = new UnityHub(options.HubPath); if (!unityHub.PathExists()) { Logger.Error("Unity hub was not found"); Environment.ExitCode = 1; return; } var version = options.Version; var changeset = options.Changeset; if (!string.IsNullOrWhiteSpace(options.HubUri)) { (version, changeset) = Helpers.ParseHubUri(options.HubUri); if (version == null || changeset == null) { Logger.Error("The passed hub URI is not in a valid format"); Environment.ExitCode = 1; return; } Logger.Debug("Uri parsed version: {0}, changeset: {1}", version, changeset); } Logger.Debug("Checking if version is already installed"); var unityInstall = unityHub.GetInstall(version); if (unityInstall != null) { if (!options.Modules.Any()) { Logger.Error("Unity version '{0}' seems to be installed already", version); Environment.ExitCode = 1; return; } } if (unityInstall == null) { Logger.Debug("Version is not yet installed"); if (!InstallVersion(unityHub, version, changeset)) { Logger.Error("Failed to install Unity version '{0}'", version); Environment.ExitCode = 1; return; } Logger.Info("Base installation done"); } else { Logger.Info("Unity version '{0}' is already installed", version); Logger.Info("Continuing with the modules"); } if (options.Modules.Any()) { if (!InstallModules(options, unityHub, version)) { return; } } Logger.Info("Installation complete"); }