Skip to content

Commit 530e566

Browse files
committed
Handle more install methods
1 parent 4470163 commit 530e566

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

source/create_dialog_derived.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ void CreateProjectDialogD::OnCreate(wxCommandEvent& event){
7171
//assemble the command that will create the project described by the dialog
7272

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

source/globals.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ struct wxWindow;
2929
static constexpr std::string_view installerExt = "dmg";
3030

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

3838
//for stream redirecting to dev/null
3939
static constexpr std::string_view null_device = ">/dev/null 2>&1";
@@ -123,6 +123,10 @@ struct editor {
123123
return path / name / executable;
124124
#endif
125125
}
126+
127+
auto templatePath() const{
128+
return path / templatesDir;
129+
}
126130

127131
bool operator==(const editor& other) {
128132
return this->name == other.name; // many editors can share a root path

source/interface_derived.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,13 +618,19 @@ void MainFrameDerived::LoadEditorVersions(){
618618
// unity versions at once, which sucks. To get the version,
619619
// we need to parse the info.plist inside of Unity.app
620620
auto infopath = entry / "Unity.app" / "Contents" / "Info.plist";
621-
if (filesystem::exists(infopath)){
621+
auto basedir = entry / "Unity.app";
622+
if (!filesystem::exists(infopath)){
623+
// maybe this was a direct install
624+
infopath = entry / "Contents" / "Info.plist";
625+
basedir = entry;
626+
}
627+
if (filesystem::exists(infopath) && infopath.string().find("Unity.app") != std::string::npos){
622628
// read the file and look for CFBundleVersion
623629
char buffer[16]{0};
624630
getCFBundleVersionFromPlist(infopath.string().c_str(), buffer, sizeof(buffer));
625631

626632
//add it to the backing datastructure
627-
editor e = {buffer, entry};
633+
editor e = {buffer, basedir};
628634
addInstall(e);
629635
}
630636
#else

0 commit comments

Comments
 (0)