-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLinuxSupport.cs
More file actions
47 lines (37 loc) · 1.65 KB
/
LinuxSupport.cs
File metadata and controls
47 lines (37 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
internal sealed class LinuxSupport : PlatformSupport
{
public override string FindInstallationRoot(string editorPath)
{
throw new NotImplementedException();
}
public override string FormatHubArgs(string args)
=> args; // Linux doesn't need the "--" prefix
public override ProcessStartInfo OpenFile(string filePath) => new("xdg-open", filePath);
public override ProcessStartInfo OpenFileWithApp(string filePath, string applicationPath)
{
// On Linux, directly execute the application with the file as argument
return new ProcessStartInfo(applicationPath, filePath);
}
public override string UnityHubConfigDirectory => Path.Combine(UserHome, ".config/UnityHub");
public override ProcessStartInfo GetUnityProjectSearchProcess()
{
// Presumably requires manual database update (at least on macOS it's not up-to-date by default).
return new ProcessStartInfo("bash",
"-c \"locate ProjectVersion.txt | grep ProjectSettings/ProjectVersion.txt\"");
}
protected override string DefaultEditorPathTemplate => Path.Combine(UserHome, "Unity/Hub/Editor/{0}/Editor/Unity");
protected override string DefaultUnityHubPath => Path.Combine(UserHome, "Applications/Unity Hub.AppImage");
public override string? GetUnityScriptingEditorPath()
{
// Read from Unity's prefs file
string prefsPath = Path.Combine(UserHome, ".config/unity3d/prefs");
if (!File.Exists(prefsPath))
return null;
// Format: kScriptsDefaultApp: /path/to/editor
return File.ReadLines(prefsPath)
.Where(line => line.StartsWith("kScriptsDefaultApp"))
.Select(line => line.Split(':', 2))
.Where(parts => parts.Length == 2)
.Select(parts => parts[1].Trim()).FirstOrDefault();
}
}