private IEnumerator ProcessCommandsCoroutine(string commandString) { //string commandString = ClipboardHelper.clipBoard; var serializer = new XmlSerializer(typeof(CommandList)); var stream = new StringReader(commandString); if (serializer.Deserialize(stream) is CommandList commandList) { foreach (var thisCommand in commandList.Commands) { switch (thisCommand.CommandType) { case CommandType.Settings: SettingsGui.Settings = thisCommand.ProjectSettings; SettingsGui.SetSettings(); break; case CommandType.Open: { StartCoroutine(_saveLoad.LoadTexture(thisCommand.MapType, thisCommand.FilePath)); while (_saveLoad.Busy) { yield return(new WaitForSeconds(0.1f)); } break; } case CommandType.Save: { switch (thisCommand.MapType) { case MapType.Height: StartCoroutine(_saveLoad.SaveTexture(thisCommand.Extension, _mainGui.HeightMap, thisCommand.FilePath)); break; case MapType.Diffuse: StartCoroutine(_saveLoad.SaveTexture(thisCommand.Extension, _mainGui.DiffuseMapOriginal, thisCommand.FilePath)); break; case MapType.Metallic: StartCoroutine(_saveLoad.SaveTexture(thisCommand.Extension, _mainGui.MetallicMap, thisCommand.FilePath)); break; case MapType.Smoothness: StartCoroutine(_saveLoad.SaveTexture(thisCommand.Extension, _mainGui.SmoothnessMap, thisCommand.FilePath)); break; case MapType.Edge: StartCoroutine(_saveLoad.SaveTexture(thisCommand.Extension, _mainGui.EdgeMap, thisCommand.FilePath)); break; case MapType.Ao: StartCoroutine( _saveLoad.SaveTexture(thisCommand.Extension, _mainGui.AoMap, thisCommand.FilePath)); break; case MapType.Property: _mainGui.ProcessPropertyMap(); StartCoroutine(_saveLoad.SaveTexture(thisCommand.Extension, _mainGui.PropertyMap, thisCommand.FilePath)); break; case MapType.DiffuseOriginal: break; case MapType.Normal: break; default: throw new ArgumentOutOfRangeException(); } while (_saveLoad.Busy) { yield return(new WaitForSeconds(0.1f)); } break; } case CommandType.FlipNormalMapY: _mainGui.FlipNormalMapY(); break; case CommandType.FileFormat: _mainGui.SetFormat(thisCommand.Extension); break; case CommandType.HeightFromDiffuse: { _mainGui.CloseWindows(); _mainGui.HeightFromDiffuseGuiObject.SetActive(true); yield return(new WaitForSeconds(0.1f)); _mainGui.HeightFromDiffuseGuiScript.InitializeTextures(); yield return(new WaitForSeconds(0.1f)); StartCoroutine(_mainGui.HeightFromDiffuseGuiScript.ProcessDiffuse()); while (_mainGui.HeightFromDiffuseGuiScript.Busy) { yield return(new WaitForSeconds(0.1f)); } StartCoroutine(_mainGui.HeightFromDiffuseGuiScript.ProcessHeight()); while (_mainGui.HeightFromDiffuseGuiScript.Busy) { yield return(new WaitForSeconds(0.1f)); } _mainGui.HeightFromDiffuseGuiScript.Close(); break; } case CommandType.NormalFromHeight: { _mainGui.CloseWindows(); _mainGui.NormalFromHeightGuiObject.SetActive(true); yield return(new WaitForSeconds(0.1f)); _mainGui.NormalFromHeightGuiScript.InitializeTextures(); yield return(new WaitForSeconds(0.1f)); StartCoroutine(_mainGui.NormalFromHeightGuiScript.ProcessHeight()); while (_mainGui.NormalFromHeightGuiScript.Busy) { yield return(new WaitForSeconds(0.1f)); } StartCoroutine(_mainGui.NormalFromHeightGuiScript.ProcessNormal()); while (_mainGui.NormalFromHeightGuiScript.Busy) { yield return(new WaitForSeconds(0.1f)); } _mainGui.NormalFromHeightGuiScript.Close(); break; } case CommandType.Metallic: { _mainGui.CloseWindows(); _mainGui.MetallicGuiObject.SetActive(true); yield return(new WaitForSeconds(0.1f)); _mainGui.MetallicGuiScript.InitializeTextures(); yield return(new WaitForSeconds(0.1f)); StartCoroutine(_mainGui.MetallicGuiScript.ProcessBlur()); while (_mainGui.MetallicGuiScript.Busy) { yield return(new WaitForSeconds(0.1f)); } StartCoroutine(_mainGui.MetallicGuiScript.ProcessMetallic()); while (_mainGui.MetallicGuiScript.Busy) { yield return(new WaitForSeconds(0.1f)); } _mainGui.MetallicGuiScript.Close(); break; } case CommandType.Smoothness: { _mainGui.CloseWindows(); _mainGui.SmoothnessGuiObject.SetActive(true); yield return(new WaitForSeconds(0.1f)); _mainGui.SmoothnessGuiScript.InitializeTextures(); yield return(new WaitForSeconds(0.1f)); StartCoroutine(_mainGui.SmoothnessGuiScript.ProcessBlur()); while (_mainGui.SmoothnessGuiScript.Busy) { yield return(new WaitForSeconds(0.1f)); } StartCoroutine(_mainGui.SmoothnessGuiScript.ProcessSmoothness()); while (_mainGui.SmoothnessGuiScript.Busy) { yield return(new WaitForSeconds(0.1f)); } _mainGui.SmoothnessGuiScript.Close(); break; } case CommandType.AoFromNormal: { _mainGui.CloseWindows(); _mainGui.AoFromNormalGuiObject.SetActive(true); yield return(new WaitForSeconds(0.1f)); _mainGui.AoFromNormalGuiScript.InitializeTextures(); yield return(new WaitForSeconds(0.1f)); StartCoroutine(_mainGui.AoFromNormalGuiScript.ProcessNormalDepth()); while (_mainGui.AoFromNormalGuiScript.Busy) { yield return(new WaitForSeconds(0.1f)); } StartCoroutine(_mainGui.AoFromNormalGuiScript.ProcessAo()); while (_mainGui.AoFromNormalGuiScript.Busy) { yield return(new WaitForSeconds(0.1f)); } _mainGui.AoFromNormalGuiScript.Close(); break; } case CommandType.EdgeFromNormal: { _mainGui.CloseWindows(); _mainGui.EdgeFromNormalGuiObject.SetActive(true); yield return(new WaitForSeconds(0.1f)); _mainGui.EdgeFromNormalGuiScript.InitializeTextures(); yield return(new WaitForSeconds(0.1f)); StartCoroutine(_mainGui.EdgeFromNormalGuiScript.ProcessNormal()); while (_mainGui.EdgeFromNormalGuiScript.Busy) { yield return(new WaitForSeconds(0.1f)); } StartCoroutine(_mainGui.EdgeFromNormalGuiScript.ProcessEdge()); while (_mainGui.EdgeFromNormalGuiScript.Busy) { yield return(new WaitForSeconds(0.1f)); } _mainGui.EdgeFromNormalGuiScript.Close(); break; } case CommandType.QuickSave: switch (thisCommand.MapType) { case MapType.Height: _mainGui.QuicksavePathHeight = thisCommand.FilePath; break; case MapType.Diffuse: _mainGui.QuicksavePathDiffuse = thisCommand.FilePath; break; case MapType.Normal: _mainGui.QuicksavePathNormal = thisCommand.FilePath; break; case MapType.Metallic: _mainGui.QuicksavePathMetallic = thisCommand.FilePath; break; case MapType.Smoothness: _mainGui.QuicksavePathSmoothness = thisCommand.FilePath; break; case MapType.Edge: _mainGui.QuicksavePathEdge = thisCommand.FilePath; break; case MapType.Ao: _mainGui.QuicksavePathAo = thisCommand.FilePath; break; case MapType.Property: _mainGui.QuicksavePathProperty = thisCommand.FilePath; break; case MapType.DiffuseOriginal: break; default: throw new ArgumentOutOfRangeException(); } break; default: throw new ArgumentOutOfRangeException(); } yield return(new WaitForSeconds(0.1f)); ClipboardHelper.ClipBoard = ""; } } yield return(new WaitForSeconds(0.1f)); _mainGui.CloseWindows(); _mainGui.FixSize(); _mainGui.MaterialGuiObject.SetActive(true); _mainGui.MaterialGuiScript.Initialize(); }
IEnumerator ProcessCommandsCoroutine(string commandString) { //string commandString = ClipboardHelper.clipBoard; var serializer = new XmlSerializer(typeof(CommandList)); var stream = new System.IO.StringReader(commandString); CommandList commandList = serializer.Deserialize(stream) as CommandList; for (int i = 0; i < commandList.commands.Count; i++) { Command thisCommand = commandList.commands[i]; if (thisCommand.commandType == CommandType.Settings) { settingsGui.settings = thisCommand.projectSettings; settingsGui.SetSettings(); } else if (thisCommand.commandType == CommandType.Open) { StartCoroutine(saveLoad.LoadTexture(thisCommand.mapType, thisCommand.filePath)); while (saveLoad.busy) { yield return(new WaitForSeconds(0.1f)); } } else if (thisCommand.commandType == CommandType.Save) { switch (thisCommand.mapType) { case MapType.height: StartCoroutine(saveLoad.SaveTexture(thisCommand.extension, mainGui._HeightMap, thisCommand.filePath)); break; case MapType.diffuse: StartCoroutine(saveLoad.SaveTexture(thisCommand.extension, mainGui._DiffuseMapOriginal, thisCommand.filePath)); break; case MapType.metallic: StartCoroutine(saveLoad.SaveTexture(thisCommand.extension, mainGui._MetallicMap, thisCommand.filePath)); break; case MapType.smoothness: StartCoroutine(saveLoad.SaveTexture(thisCommand.extension, mainGui._SmoothnessMap, thisCommand.filePath)); break; case MapType.edge: StartCoroutine(saveLoad.SaveTexture(thisCommand.extension, mainGui._EdgeMap, thisCommand.filePath)); break; case MapType.ao: StartCoroutine(saveLoad.SaveTexture(thisCommand.extension, mainGui._AOMap, thisCommand.filePath)); break; case MapType.property: mainGui.ProcessPropertyMap(); StartCoroutine(saveLoad.SaveTexture(thisCommand.extension, mainGui._PropertyMap, thisCommand.filePath)); break; default: break; } while (saveLoad.busy) { yield return(new WaitForSeconds(0.1f)); } } else if (thisCommand.commandType == CommandType.FlipNormalMapY) { mainGui.FlipNormalMapY(); } else if (thisCommand.commandType == CommandType.FileFormat) { mainGui.SetFormat(thisCommand.extension); } else if (thisCommand.commandType == CommandType.HeightFromDiffuse) { mainGui.CloseWindows(); heightFromDiffuseGuiObject.SetActive(true); yield return(new WaitForSeconds(0.1f)); heightFromDiffuseGui.InitializeTextures(); yield return(new WaitForSeconds(0.1f)); StartCoroutine(heightFromDiffuseGui.ProcessDiffuse()); while (heightFromDiffuseGui.busy) { yield return(new WaitForSeconds(0.1f)); } StartCoroutine(heightFromDiffuseGui.ProcessHeight()); while (heightFromDiffuseGui.busy) { yield return(new WaitForSeconds(0.1f)); } heightFromDiffuseGui.Close(); } else if (thisCommand.commandType == CommandType.NormalFromHeight) { mainGui.CloseWindows(); normalFromHeightGuiObject.SetActive(true); yield return(new WaitForSeconds(0.1f)); normalFromHeightGui.InitializeTextures(); yield return(new WaitForSeconds(0.1f)); StartCoroutine(normalFromHeightGui.ProcessHeight()); while (normalFromHeightGui.busy) { yield return(new WaitForSeconds(0.1f)); } StartCoroutine(normalFromHeightGui.ProcessNormal()); while (normalFromHeightGui.busy) { yield return(new WaitForSeconds(0.1f)); } normalFromHeightGui.Close(); } else if (thisCommand.commandType == CommandType.Metallic) { mainGui.CloseWindows(); metallicGuiObject.SetActive(true); yield return(new WaitForSeconds(0.1f)); metallicGui.InitializeTextures(); yield return(new WaitForSeconds(0.1f)); StartCoroutine(metallicGui.ProcessBlur()); while (metallicGui.busy) { yield return(new WaitForSeconds(0.1f)); } StartCoroutine(metallicGui.ProcessMetallic()); while (metallicGui.busy) { yield return(new WaitForSeconds(0.1f)); } metallicGui.Close(); } else if (thisCommand.commandType == CommandType.Smoothness) { mainGui.CloseWindows(); smoothnessGuiObject.SetActive(true); yield return(new WaitForSeconds(0.1f)); smoothnessGui.InitializeTextures(); yield return(new WaitForSeconds(0.1f)); StartCoroutine(smoothnessGui.ProcessBlur()); while (smoothnessGui.busy) { yield return(new WaitForSeconds(0.1f)); } StartCoroutine(smoothnessGui.ProcessSmoothness()); while (smoothnessGui.busy) { yield return(new WaitForSeconds(0.1f)); } smoothnessGui.Close(); } else if (thisCommand.commandType == CommandType.AOFromNormal) { mainGui.CloseWindows(); aoFromNormalGuiObject.SetActive(true); yield return(new WaitForSeconds(0.1f)); aoFromNormalGui.InitializeTextures(); yield return(new WaitForSeconds(0.1f)); StartCoroutine(aoFromNormalGui.ProcessNormalDepth()); while (aoFromNormalGui.busy) { yield return(new WaitForSeconds(0.1f)); } StartCoroutine(aoFromNormalGui.ProcessAO()); while (aoFromNormalGui.busy) { yield return(new WaitForSeconds(0.1f)); } aoFromNormalGui.Close(); } else if (thisCommand.commandType == CommandType.EdgeFromNormal) { mainGui.CloseWindows(); edgeFromNormalGuiObject.SetActive(true); yield return(new WaitForSeconds(0.1f)); edgeFromNormalGui.InitializeTextures(); yield return(new WaitForSeconds(0.1f)); StartCoroutine(edgeFromNormalGui.ProcessNormal()); while (edgeFromNormalGui.busy) { yield return(new WaitForSeconds(0.1f)); } StartCoroutine(edgeFromNormalGui.ProcessEdge()); while (edgeFromNormalGui.busy) { yield return(new WaitForSeconds(0.1f)); } edgeFromNormalGui.Close(); } else if (thisCommand.commandType == CommandType.QuickSave) { switch (thisCommand.mapType) { case MapType.height: mainGui.QuicksavePathHeight = thisCommand.filePath; break; case MapType.diffuse: mainGui.QuicksavePathDiffuse = thisCommand.filePath; break; case MapType.normal: mainGui.QuicksavePathNormal = thisCommand.filePath; break; case MapType.metallic: mainGui.QuicksavePathMetallic = thisCommand.filePath; break; case MapType.smoothness: mainGui.QuicksavePathSmoothness = thisCommand.filePath; break; case MapType.edge: mainGui.QuicksavePathEdge = thisCommand.filePath; break; case MapType.ao: mainGui.QuicksavePathAO = thisCommand.filePath; break; case MapType.property: mainGui.QuicksavePathProperty = thisCommand.filePath; break; default: break; } } yield return(new WaitForSeconds(0.1f)); ClipboardHelper.clipBoard = ""; } yield return(new WaitForSeconds(0.1f)); mainGui.CloseWindows(); mainGui.FixSize(); materialGuiObject.SetActive(true); materialGui.Initialize(); }