/// <summary> /// Downloads and extracts the Core Sdk and associated libraries and tools. /// </summary> private static DownloadResult Download() { RemoveMarkerFile(); int exitCode; try { EditorApplication.LockReloadAssemblies(); using (new ShowProgressBarScope($"Installing SpatialOS libraries, version {Common.CoreSdkVersion}...")) { exitCode = RedirectedProcess.Run(Common.DotNetBinary, "run", "-p", $"\"{ProjectPath}\"", "--", $"\"{Common.SpatialBinary}\"", $"\"{Common.CoreSdkVersion}\""); if (exitCode != 0) { Debug.LogError($"Failed to download SpatialOS Core Sdk version {Common.CoreSdkVersion}."); } else { File.WriteAllText(InstallMarkerFile, string.Empty); } } } finally { EditorApplication.UnlockReloadAssemblies(); } return(exitCode == 0 ? DownloadResult.Success : DownloadResult.Error); }
/// <summary> /// Downloads and extracts the Core Sdk and associated libraries and tools. /// </summary> private static DownloadResult Download() { RemoveMarkerFile(); int exitCode; try { EditorApplication.LockReloadAssemblies(); using (new ShowProgressBarScope($"Installing SpatialOS libraries, version {Common.CoreSdkVersion}...")) { exitCode = RedirectedProcess.Run(Common.DotNetBinary, ConstructArguments()); if (exitCode != 0) { Debug.LogError($"Failed to download SpatialOS Core Sdk version {Common.CoreSdkVersion}. You can use SpatialOS -> Download CoreSDK (force) to retry this."); } else { File.WriteAllText(InstallMarkerFile, string.Empty); } } } finally { EditorApplication.UnlockReloadAssemblies(); } return(exitCode == 0 ? DownloadResult.Success : DownloadResult.Error); }
private static void Generate() { try { EditorApplication.LockReloadAssemblies(); // Ensure that all dependencies are in place. if (DownloadCoreSdk.TryDownload() == DownloadResult.Error) { return; } CopySchema(); var projectPath = Path.GetFullPath(Path.Combine(Common.GetThisPackagePath(), CsProjectFile)); var schemaCompilerPath = Path.GetFullPath(Path.Combine(Application.dataPath, SchemaCompilerRelativePath)); var workerJsonPath = Path.GetFullPath(Path.Combine(Application.dataPath, "..")); switch (Application.platform) { case RuntimePlatform.WindowsEditor: schemaCompilerPath = Path.ChangeExtension(schemaCompilerPath, ".exe"); break; case RuntimePlatform.LinuxEditor: case RuntimePlatform.OSXEditor: // Ensure the schema compiler is executable. var _ = RedirectedProcess.Run("chmod", "+x", schemaCompilerPath); break; default: throw new PlatformNotSupportedException( $"The {Application.platform} platform does not support code generation."); } using (new ShowProgressBarScope("Generating code...")) { var exitCode = RedirectedProcess.Run(Common.DotNetBinary, ConstructArgs(projectPath, schemaCompilerPath, workerJsonPath)); if (exitCode != 0) { Debug.LogError("Failed to generate code."); } else { File.WriteAllText(StartupCodegenMarkerFile, string.Empty); } } AssetDatabase.Refresh(); } catch (Exception e) { Debug.LogException(e); } finally { EditorApplication.UnlockReloadAssemblies(); } }
private static void Generate() { try { EditorApplication.LockReloadAssemblies(); // Ensure that all dependencies are in place. if (DownloadCoreSdk.TryDownload() == DownloadResult.Error) { return; } CopySchema(SchemaRootDir); var projectPath = Path.GetFullPath(Path.Combine(Common.GetThisPackagePath(), CsProjectFile)); var schemaCompilerPath = Path.GetFullPath(Path.Combine(Application.dataPath, SchemaCompilerRelativePath)); switch (Application.platform) { case RuntimePlatform.WindowsEditor: schemaCompilerPath = Path.ChangeExtension(schemaCompilerPath, ".exe"); break; case RuntimePlatform.LinuxEditor: case RuntimePlatform.OSXEditor: // Ensure the schema compiler is executable. var _ = RedirectedProcess.Run("chmod", "+x", schemaCompilerPath); break; default: throw new PlatformNotSupportedException( $"The {Application.platform} platform does not support code generation."); } using (new ShowProgressBarScope("Generating code...")) { var exitCode = RedirectedProcess.Run(Common.DotNetBinary, "run", "-p", $"\"{projectPath}\"", "--", $"--schema-path=\"{SchemaRootDir}\"", $"--schema-path={SchemaStandardLibraryDir}", $"--json-dir={ImprobableJsonDir}", $"--native-output-dir={AssetsGeneratedSourceDir}", $"--schema-compiler-path=\"{schemaCompilerPath}\""); if (exitCode != 0) { Debug.LogError("Failed to generate code."); } } AssetDatabase.Refresh(); } catch (Exception e) { Debug.LogException(e); } finally { EditorApplication.UnlockReloadAssemblies(); } }