From 27f217ef989fc88543f0f3e92170e7ca97af6ae6 Mon Sep 17 00:00:00 2001 From: Richard Marcus <richard.marcus@fau.de> Date: Sun, 29 Mar 2020 19:22:50 +0200 Subject: [PATCH] .bat can now handle spaces, server cannot --- Assets/StartServer.cs | 62 ++++++++++++++++++++--- ProjectSettings/EditorBuildSettings.asset | 8 ++- ProjectSettings/GraphicsSettings.asset | 3 ++ ProjectSettings/ProjectSettings.asset | 7 +-- 4 files changed, 70 insertions(+), 10 deletions(-) diff --git a/Assets/StartServer.cs b/Assets/StartServer.cs index bbdda28e..bd470d48 100644 --- a/Assets/StartServer.cs +++ b/Assets/StartServer.cs @@ -25,18 +25,68 @@ void PrepareGame() } - IEnumerator ServerRoutine() + IEnumerator ServerRoutine1() { + string command = "\"" + Application.streamingAssetsPath + "\"/start.BAT "+ "\"" + Application.streamingAssetsPath + "\"" ; + command = command.Replace("/", @"\"); + command = "\"" + command + "\""; + UnityEngine.Debug.Log(command); + ProcessStartInfo processInfo; + Process process; + + //processInfo = new ProcessStartInfo("cmd.exe", "/C " + command); + bool cmd = true; + if (cmd) + { + processInfo = new ProcessStartInfo("cmd.exe", "/C " + command); + // processInfo.CreateNoWindow = false; + // processInfo.UseShellExecute = true; + + process = Process.Start(processInfo); + }else + /* + */ + Process.Start("powershell.exe", command); + + + + + // *** Read the streams *** + // Warning: This approach can lead to deadlocks, see Edit #2 + //string output = process.StandardOutput.ReadToEnd(); + //string error = process.StandardError.ReadToEnd(); + + // exitCode = process.ExitCode; + // UnityEngine.Debug.Log(output); + // UnityEngine.Debug.Log(error); + // Console.WriteLine("output>>" + (String.IsNullOrEmpty(output) ? "(none)" : output)); + // Console.WriteLine("error>>" + (String.IsNullOrEmpty(error) ? "(none)" : error)); + // Console.WriteLine("ExitCode: " + exitCode.ToString(), "ExecuteCommand"); + // process.Close(); + + + + + + + yield return null; + } + + + IEnumerator ServerRoutine() + { UnityWebRequest request = UnityWebRequest.Get("localhost:8081/scroll/list"); - yield return request.Send(); + yield return request.SendWebRequest(); if (request.isNetworkError || request.isHttpError) { UnityEngine.Debug.Log("no running server"); - string command = Application.streamingAssetsPath + "/start.BAT " + Application.streamingAssetsPath; + string command = "\"" + Application.streamingAssetsPath + "\"/start.BAT " + "\"" + Application.streamingAssetsPath + "\""; + command = command.Replace("/", @"\"); + command = "\"" + command + "\""; UnityEngine.Debug.Log(command); - int exitCode; + // int exitCode; ProcessStartInfo processInfo; Process process; @@ -53,10 +103,10 @@ IEnumerator ServerRoutine() while (true) { request = UnityWebRequest.Get("localhost:8081/scroll/list"); - yield return request.Send(); + yield return request.SendWebRequest(); if (request.isNetworkError || request.isHttpError) { - UnityEngine.Debug.Log("no running server"); + // UnityEngine.Debug.Log("no running server"); } else { diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 0147887e..b2d04814 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -4,5 +4,11 @@ EditorBuildSettings: m_ObjectHideFlags: 0 serializedVersion: 2 - m_Scenes: [] + m_Scenes: + - enabled: 1 + path: Assets/StartScreen.unity + guid: 80736d45fa76e1b488eab0eb8650ff3d + - enabled: 1 + path: Assets/TreeWorld_02.unity + guid: 9b8063e1ae3c04045b13e20d1ccc73d0 m_configObjects: {} diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset index cd1c3d65..79974606 100644 --- a/ProjectSettings/GraphicsSettings.asset +++ b/ProjectSettings/GraphicsSettings.asset @@ -36,6 +36,8 @@ GraphicsSettings: - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} m_PreloadedShaders: [] m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} @@ -60,3 +62,4 @@ GraphicsSettings: m_AlbedoSwatchInfos: [] m_LightsUseLinearIntensity: 0 m_LightsUseColorTemperature: 0 + m_LogWhenShaderIsCompiled: 0 diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 3e003425..16a58a1c 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -12,8 +12,8 @@ PlayerSettings: targetDevice: 2 useOnDemandResources: 0 accelerometerFrequency: 60 - companyName: DefaultCompany - productName: New Unity Project + companyName: KWARC + productName: FrameWorld1 defaultCursor: {fileID: 0} cursorHotspot: {x: 0, y: 0} m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} @@ -155,7 +155,8 @@ PlayerSettings: resolutionScalingMode: 0 androidSupportedAspectRatio: 1 androidMaxAspectRatio: 2.1 - applicationIdentifier: {} + applicationIdentifier: + Standalone: com.KWARC.FrameIT buildNumber: {} AndroidBundleVersionCode: 1 AndroidMinSdkVersion: 16 -- GitLab