Skip to content

Commit

Permalink
Fix mac build
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravbug committed Nov 10, 2023
1 parent c482a8d commit 7152d09
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Build-Release
on: push
on: [push, pull_request]
jobs:
build-linux:
name: Build App for Linux x64
Expand Down
66 changes: 38 additions & 28 deletions source/interface_derived.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7152d09

Please sign in to comment.