Skip to content

Commit 7152d09

Browse files
committed
Fix mac build
1 parent c482a8d commit 7152d09

File tree

2 files changed

+39
-29
lines changed

2 files changed

+39
-29
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Build-Release
2-
on: push
2+
on: [push, pull_request]
33
jobs:
44
build-linux:
55
name: Build App for Linux x64

source/interface_derived.cpp

+38-28
Original file line numberDiff line numberDiff line change
@@ -391,37 +391,47 @@ void MainFrameDerived::OnOpenWith(wxCommandEvent& event){
391391
@param index the integer representing which project in the projects Vector to load
392392
*/
393393
void MainFrameDerived::OpenProject(const long& index){
394-
//get the project
395-
project p = projects[index];
396-
397-
for (const auto& path : installPaths) {
398-
auto editorPath = path / p.version / executable;
399-
400-
//check that the unity editor exists at that location
401-
if (filesystem::exists(editorPath)) {
402-
403-
string cmd = "\"" + editorPath.string() + "\" -projectpath \"" + p.path.string() + "\"";
394+
//get the project
395+
project p = projects[index];
404396

405-
//start the process
406-
launch_process(cmd);
397+
if (!std::filesystem::exists(p.path)) {
398+
wxMessageBox("Cannot open project at " + p.path.string() + " because it could not be found.", "Cannot Open Project", wxOK | wxICON_ERROR);
399+
return;
400+
}
407401

408-
return;
409-
}
402+
for (const auto& editor : editors) {
403+
if (editor.name.find(p.version) == std::string::npos)
404+
continue;
405+
406+
auto editorPath = editor.executablePath();
407+
//check that the unity editor exists at that location
408+
if (filesystem::exists(editorPath)) {
409+
410+
string cmd = "\"" + editorPath.string() + "\" -projectpath \"" + p.path.string() + "\"";
411+
412+
//start the process
413+
launch_process(cmd);
414+
415+
return;
416+
}
417+
}
410418
#if __APPLE__
411-
else if (filesystem::exists(path / executable)) {
412-
// mac unlabeled version
413-
auto unlabeledPath = path / executable;
414-
char buffer[16];
415-
auto unlabeledPathInfo = path / "Unity.app" / "Contents" / "Info.plist";
416-
getCFBundleVersionFromPlist(unlabeledPathInfo.string().c_str(), buffer, sizeof(buffer));
417-
if (p.version == buffer) {
418-
string cmd = "\"" + unlabeledPath.string() + "\" -projectpath \"" + p.path.string() + "\"";
419-
launch_process(cmd);
420-
return;
421-
}
422-
}
423-
#endif
424-
}
419+
for (const auto& path : installPaths) {
420+
if (filesystem::exists(path / executable)) {
421+
// mac unlabeled version
422+
auto unlabeledPath = path / executable;
423+
char buffer[16];
424+
auto unlabeledPathInfo = path / "Unity.app" / "Contents" / "Info.plist";
425+
getCFBundleVersionFromPlist(unlabeledPathInfo.string().c_str(), buffer, sizeof(buffer));
426+
if (p.version == buffer) {
427+
string cmd = "\"" + unlabeledPath.string() + "\" -projectpath \"" + p.path.string() + "\"";
428+
launch_process(cmd);
429+
return;
430+
}
431+
}
432+
#endif
433+
}
434+
425435
// prompt the user to choose a new editor because we couldn't locate one
426436
wxCommandEvent evt;
427437
MainFrameDerived::OnOpenWith(evt);

0 commit comments

Comments
 (0)