Skip to content

Commit

Permalink
Handle more install methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravbug committed Sep 26, 2024
1 parent 4470163 commit 530e566
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions source/create_dialog_derived.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ void CreateProjectDialogD::OnCreate(wxCommandEvent& event){
//assemble the command that will create the project described by the dialog

editor& e = editors[GetSelectedEditorIndex()];
auto executablePath = e.path / e.name / executable;
auto executableTemplatesPath = e.path / e.name / templatesDir;
auto executablePath = e.executablePath();
auto executableTemplatesPath = e.templatePath();
string projName = projNameTxt->GetValue().ToStdString();
string projPath = projLocTxt->GetValue().ToStdString();

Expand Down
8 changes: 6 additions & 2 deletions source/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ struct wxWindow;
static constexpr std::string_view installerExt = "dmg";

//where to find various Unity things on macOS
static const std::filesystem::path executable = "Unity.app/Contents/MacOS/Unity";
static const std::filesystem::path executable = "Contents/MacOS/Unity";
static const std::vector<std::filesystem::path> defaultInstall = {"/Applications/Unity/Hub/Editor","/Applications/Unity/"};
//TODO: make this a preference?
static const std::filesystem::path hubDefault = "/Applications/Unity Hub.app";
static const std::filesystem::path templatesDir = "Unity.app/Contents/Resources/PackageManager/ProjectTemplates/";
static const std::filesystem::path templatesDir = "Contents/Resources/PackageManager/ProjectTemplates/";

//for stream redirecting to dev/null
static constexpr std::string_view null_device = ">/dev/null 2>&1";
Expand Down Expand Up @@ -123,6 +123,10 @@ struct editor {
return path / name / executable;
#endif
}

auto templatePath() const{
return path / templatesDir;
}

bool operator==(const editor& other) {
return this->name == other.name; // many editors can share a root path
Expand Down
10 changes: 8 additions & 2 deletions source/interface_derived.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,13 +618,19 @@ void MainFrameDerived::LoadEditorVersions(){
// unity versions at once, which sucks. To get the version,
// we need to parse the info.plist inside of Unity.app
auto infopath = entry / "Unity.app" / "Contents" / "Info.plist";
if (filesystem::exists(infopath)){
auto basedir = entry / "Unity.app";
if (!filesystem::exists(infopath)){
// maybe this was a direct install
infopath = entry / "Contents" / "Info.plist";
basedir = entry;
}
if (filesystem::exists(infopath) && infopath.string().find("Unity.app") != std::string::npos){
// read the file and look for CFBundleVersion
char buffer[16]{0};
getCFBundleVersionFromPlist(infopath.string().c_str(), buffer, sizeof(buffer));

//add it to the backing datastructure
editor e = {buffer, entry};
editor e = {buffer, basedir};
addInstall(e);
}
#else
Expand Down

0 comments on commit 530e566

Please sign in to comment.