diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6c7add5a..48d7e745 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,5 @@ name: Build-Release -on: push +on: [push, pull_request] jobs: build-linux: name: Build App for Linux x64 diff --git a/source/interface_derived.cpp b/source/interface_derived.cpp index 32b20012..bc1f2c3c 100644 --- a/source/interface_derived.cpp +++ b/source/interface_derived.cpp @@ -391,37 +391,47 @@ void MainFrameDerived::OnOpenWith(wxCommandEvent& event){ @param index the integer representing which project in the projects Vector to load */ void MainFrameDerived::OpenProject(const long& index){ - //get the project - project p = projects[index]; - - for (const auto& path : installPaths) { - auto editorPath = path / p.version / executable; - - //check that the unity editor exists at that location - if (filesystem::exists(editorPath)) { - - string cmd = "\"" + editorPath.string() + "\" -projectpath \"" + p.path.string() + "\""; + //get the project + project p = projects[index]; - //start the process - launch_process(cmd); + if (!std::filesystem::exists(p.path)) { + wxMessageBox("Cannot open project at " + p.path.string() + " because it could not be found.", "Cannot Open Project", wxOK | wxICON_ERROR); + return; + } - return; - } + for (const auto& editor : editors) { + if (editor.name.find(p.version) == std::string::npos) + continue; + + auto editorPath = editor.executablePath(); + //check that the unity editor exists at that location + if (filesystem::exists(editorPath)) { + + string cmd = "\"" + editorPath.string() + "\" -projectpath \"" + p.path.string() + "\""; + + //start the process + launch_process(cmd); + + return; + } + } #if __APPLE__ - else if (filesystem::exists(path / executable)) { - // mac unlabeled version - auto unlabeledPath = path / executable; - char buffer[16]; - auto unlabeledPathInfo = path / "Unity.app" / "Contents" / "Info.plist"; - getCFBundleVersionFromPlist(unlabeledPathInfo.string().c_str(), buffer, sizeof(buffer)); - if (p.version == buffer) { - string cmd = "\"" + unlabeledPath.string() + "\" -projectpath \"" + p.path.string() + "\""; - launch_process(cmd); - return; - } - } -#endif - } + for (const auto& path : installPaths) { + if (filesystem::exists(path / executable)) { + // mac unlabeled version + auto unlabeledPath = path / executable; + char buffer[16]; + auto unlabeledPathInfo = path / "Unity.app" / "Contents" / "Info.plist"; + getCFBundleVersionFromPlist(unlabeledPathInfo.string().c_str(), buffer, sizeof(buffer)); + if (p.version == buffer) { + string cmd = "\"" + unlabeledPath.string() + "\" -projectpath \"" + p.path.string() + "\""; + launch_process(cmd); + return; + } + } +#endif + } + // prompt the user to choose a new editor because we couldn't locate one wxCommandEvent evt; MainFrameDerived::OnOpenWith(evt);