/// <summary> /// /// </summary> internal static void DebugGame() { if (SceneManager.ActiveScene == null) { MessageBox.Show("Ups!\n\nThere is no scene loaded", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } SceneManager.GameProject.SceneStartPath = GibboHelper.MakeExclusiveRelativePath(SceneManager.GameProject.ProjectPath, SceneManager.ActiveScenePath); SaveProject(); SaveScene(false); if (File.Exists(SceneManager.GameProject.ProjectPath + "\\Gibbo.Engine.Windows.exe")) { if (File.Exists(SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll")) File.Delete(SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll"); if (!Directory.Exists(SceneManager.GameProject.ProjectPath + "\\libs")) Directory.CreateDirectory(SceneManager.GameProject.ProjectPath + "\\libs"); // Compile scripts: // old (depracated): CompileScripts(false); //if (SceneManager.ScriptsAssembly != null) //{ string dllpath = SceneManager.GameProject.ProjectPath + "\\bin\\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + SceneManager.ScriptsAssembly.GetName().Name + ".dll"; // The scripts .dll exists? if (!File.Exists(dllpath)) { // Compile scripts CompilerWindow cf = new CompilerWindow(); cf.ShowDialog(); if (cf.DialogResult.Value) return; // Update path dllpath = SceneManager.GameProject.ProjectPath + "\\bin\\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + SceneManager.ScriptsAssembly.GetName().Name + ".dll"; } File.Copy(dllpath, SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll", true); try { Process debug = new Process(); debug.StartInfo.WorkingDirectory = SceneManager.GameProject.ProjectPath; debug.StartInfo.FileName = SceneManager.GameProject.ProjectPath + "\\Gibbo.Engine.Windows.exe"; debug.StartInfo.Arguments = ""; debug.StartInfo.CreateNoWindow = true; debug.Start(); if (Properties.Settings.Default.AttachVisualStudio) { EnvDTE.DTE vsInstance; // Try to restore the current project visual studio solution instance, returning it if successful if (TryToRestoreSolution(out vsInstance)) { // Tries to attach the retrieved instance to the game debug process debug.Attach(vsInstance); } /* if (VisualStudioInstancePID != 0 && Extensions.TryToRetrieveVSInstance(VisualStudioInstancePID, out vsInstance)) { // restore window, in case the process is only running on background vsInstance.MainWindow.Visible = true; debug.Attach(vsInstance); } else // if PID attempt failed, try using the project solution name { // reset PID VisualStudioInstancePID = 0; // try to retrieve instance based on solution name vsInstance = Extensions.GetInstance(UserPreferences.Instance.ProjectSlnFilePath); if (vsInstance != null) { // restore window, in case the process is only running on background vsInstance.MainWindow.Visible = true; debug.Attach(vsInstance); // Attach visual studio dte } }*/ } debug.WaitForExit(); debug.Close(); } catch (Exception ex) { Console.WriteLine("ERROR: " + ex.Message); } } else { MessageBox.Show("Ups!\n\nIt seems there is no engine set up for your game!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// /// </summary> internal static void DebugGame() { if (SceneManager.ActiveScene == null) { MessageBox.Show("Ups!\n\nThere is no scene loaded", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } SceneManager.GameProject.SceneStartPath = GibboHelper.MakeExclusiveRelativePath(SceneManager.GameProject.ProjectPath, SceneManager.ActiveScenePath); SaveProject(); SaveScene(false); if (File.Exists(SceneManager.GameProject.ProjectPath + "\\Gibbo.Engine.Windows.exe")) { if (File.Exists(SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll")) File.Delete(SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll"); if (!Directory.Exists(SceneManager.GameProject.ProjectPath + "\\libs")) Directory.CreateDirectory(SceneManager.GameProject.ProjectPath + "\\libs"); // Compile scripts: // old (depracated): CompileScripts(false); //if (SceneManager.ScriptsAssembly != null) //{ string dllpath = SceneManager.GameProject.ProjectPath + "\\bin\\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + SceneManager.ScriptsAssembly.GetName().Name + ".dll"; // The scripts .dll exists? if (!File.Exists(dllpath)) { // Compile scripts CompilerWindow cf = new CompilerWindow(); cf.ShowDialog(); if (cf.DialogResult.Value) return; // Update path dllpath = SceneManager.GameProject.ProjectPath + "\\bin\\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + SceneManager.ScriptsAssembly.GetName().Name + ".dll"; } File.Copy(dllpath, SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll", true); try { Process debug = new Process(); debug.StartInfo.WorkingDirectory = SceneManager.GameProject.ProjectPath; debug.StartInfo.FileName = SceneManager.GameProject.ProjectPath + "\\Gibbo.Engine.Windows.exe"; debug.StartInfo.Arguments = ""; debug.StartInfo.CreateNoWindow = true; debug.Start(); if (Properties.Settings.Default.AttachVisualStudio) { EnvDTE.DTE instance = Extensions.GetInstance(UserPreferences.Instance.ProjectSlnFilePath); if (instance != null) { debug.Attach(instance); // Attach visual studio dte } } debug.WaitForExit(); debug.Close(); } catch (Exception ex) { Console.WriteLine("ERROR: " + ex.Message); } } else { MessageBox.Show("Ups!\n\nIt seems there is no engine set up for your game!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }