-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
24 changed files
with
629 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using System.Threading; | ||
|
||
namespace Flow.Launcher.Plugin.UnityLauncherPlugin | ||
{ | ||
public class UnityLauncherPlugin : IAsyncPlugin | ||
{ | ||
private PluginInitContext _context; | ||
|
||
public async Task InitAsync(PluginInitContext context) | ||
{ | ||
_context = context; | ||
|
||
await LoadHubAmdProjectData(); | ||
} | ||
|
||
public async Task<List<Result>> QueryAsync (Query query, CancellationToken cancellationToken) | ||
{ | ||
return await Task.Run(() => | ||
{ | ||
string userQuery = query.Search.ToString().Trim(); | ||
|
||
if (userQuery.ToLower() == "/dc") | ||
{ | ||
Parts.editor.DeleteCacheFile(); | ||
} | ||
|
||
Parts.projects.projectsMatchingQuery = Parts.projects.GetProjectsMatchingQuery(userQuery); | ||
|
||
List<Result> results = CreateListOfResults(Parts.projects.projectsMatchingQuery); | ||
|
||
return results; | ||
}, cancellationToken ); | ||
} | ||
|
||
public async Task LoadHubAmdProjectData () | ||
{ | ||
// Get Unity Hub's location | ||
Parts.hub.unityHubInstallPath = Parts.hub.GetUnityHubLocation(); | ||
|
||
bool versionCacheExists = Parts.editor.VersionCacheFileExists(); | ||
|
||
// Get location of all installed editor versions | ||
switch (versionCacheExists) | ||
{ | ||
case false: | ||
Parts.hub.FindInstalledEditors(); | ||
Parts.editor.SaveUnityVersopns(); | ||
break; | ||
|
||
case true: | ||
Parts.editor.LoadUnityVersions(); | ||
break; | ||
} | ||
|
||
// Find all projects listed in Unity Hub | ||
Parts.projects.FindUnityProjects(); | ||
} | ||
|
||
private List<Result> CreateListOfResults (List<ProjectInfoModel> projects) | ||
{ | ||
List<Result> results = new(); | ||
string projectDetails = ""; | ||
|
||
foreach (ProjectInfoModel project in projects) | ||
{ | ||
string editorVersion = project.editorVersion; | ||
bool editorVersionIsInstalled = Parts.editor.DoesEditorVersionExist(project.editorVersion); | ||
|
||
string isProjectStarred = project.isFavourite; | ||
string resultIconPath = @"Images\logo.png"; | ||
string detailSplitter = " | "; | ||
|
||
// Project is starred | ||
if (isProjectStarred.ToLower() == "true") | ||
{ | ||
resultIconPath = @"Images\fav.png"; | ||
} | ||
|
||
// Editor version is installed | ||
if (editorVersionIsInstalled) | ||
{ | ||
projectDetails = project.path + detailSplitter + "Modified: " + project.lastModified + detailSplitter + "Version: " + editorVersion; | ||
} | ||
// Editor version is missing | ||
else | ||
{ | ||
resultIconPath = @"Images\warning.png"; | ||
projectDetails = "Missing version " + editorVersion + "!" + detailSplitter + project.path + | ||
detailSplitter + "Modified: " + project.lastModified; | ||
} | ||
|
||
// Editor version is NOT installed | ||
if (!editorVersionIsInstalled) | ||
{ | ||
|
||
results.Add(new Result | ||
{ | ||
Title = project.title, | ||
SubTitle = projectDetails, | ||
IcoPath = resultIconPath, | ||
Action = _ => | ||
{ | ||
_context.API.ShowMsgError("Version was not found!", | ||
"Please install Unity " + editorVersion + " to open this project " + | ||
"or use Uity Hub to open the project in a different version"); | ||
return true; | ||
} | ||
}); | ||
} | ||
// Editor version is installed | ||
else | ||
{ | ||
results.Add(new Result | ||
{ | ||
Title = project.title, | ||
SubTitle = projectDetails, | ||
IcoPath = resultIconPath, | ||
Action = _ => | ||
{ | ||
string editorPath = Parts.editor.GetMatchingEditorVersionForProject(project.editorVersion); | ||
Parts.editor.OpenProjectIneditor(editorPath, project.path); | ||
|
||
return true; | ||
} | ||
}); | ||
} | ||
} | ||
|
||
// Replace list of results with "No results" message | ||
if (projects.Count < 1) | ||
{ | ||
results = NoResultsMessage(); | ||
} | ||
|
||
return results; | ||
} | ||
|
||
private static List<Result> NoResultsMessage () | ||
{ | ||
List<Result> results = new() | ||
{ | ||
new Result | ||
{ | ||
Title = "No results", | ||
SubTitle = "", | ||
IcoPath = @"Images\logo.png", | ||
Action = _ => | ||
{ | ||
return true; | ||
} | ||
} | ||
}; | ||
return results; | ||
} | ||
} // main class end | ||
} // namespace end |
Binary file added
BIN
+17 KB
...her.Plugin.UnityLauncherPlugin/bin/x64/Debug/Flow.Launcher.Plugin.UnityLauncherPlugin.dll
Binary file not shown.
Binary file added
BIN
+17.3 KB
...her.Plugin.UnityLauncherPlugin/bin/x64/Debug/Flow.Launcher.Plugin.UnityLauncherPlugin.pdb
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
Flow.Launcher.Plugin.UnityLauncherPlugin/bin/x64/Debug/plugin.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"ID": "8de584c0-f855-4825-8886-65e670ebe441", | ||
"ActionKeyword": "u", | ||
"Name": "UnityLauncherPlugin", | ||
"Description": "adds an option to launch Unity projects from Flow Launcher", | ||
"Author": "Ghost-Miner", | ||
"Version": "1.1.0", | ||
"Language": "csharp", | ||
"Website": "https://github.com/Ghost-Miner/Unity-project-launcher-plugin", | ||
"IcoPath": "Images\\logo.png", | ||
"ExecuteFileName": "Flow.Launcher.Plugin.UnityLauncherPlugin.dll" | ||
} |
Binary file added
BIN
+16 KB
...r.Plugin.UnityLauncherPlugin/bin/x64/Release/Flow.Launcher.Plugin.UnityLauncherPlugin.dll
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
Flow.Launcher.Plugin.UnityLauncherPlugin/bin/x64/Release/plugin.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"ID": "8de584c0-f855-4825-8886-65e670ebe441", | ||
"ActionKeyword": "u", | ||
"Name": "UnityLauncherPlugin", | ||
"Description": "adds an option to launch Unity projects from Flow Launcher", | ||
"Author": "Ghost-Miner", | ||
"Version": "1.1.0", | ||
"Language": "csharp", | ||
"Website": "https://github.com/Ghost-Miner/Unity-project-launcher-plugin", | ||
"IcoPath": "Images\\logo.png", | ||
"ExecuteFileName": "Flow.Launcher.Plugin.UnityLauncherPlugin.dll" | ||
} |
25 changes: 25 additions & 0 deletions
25
...in.UnityLauncherPlugin/obj/Debug/Flow.Launcher.Plugin.UnityLauncherPlugin.AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if | ||
// the code is regenerated. | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
|
||
using System; | ||
using System.Reflection; | ||
|
||
[assembly: System.Reflection.AssemblyCompanyAttribute("Ghost-Miner")] | ||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] | ||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] | ||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] | ||
[assembly: System.Reflection.AssemblyProductAttribute("Flow.Launcher.Plugin.UnityLauncherPlugin")] | ||
[assembly: System.Reflection.AssemblyTitleAttribute("Flow.Launcher.Plugin.UnityLauncherPlugin")] | ||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] | ||
[assembly: System.Reflection.AssemblyMetadataAttribute("RepositoryUrl", "https://github.com/Ghost-Miner/Flow.Launcher.Plugin.UnityLauncherPlugin")] | ||
[assembly: System.Runtime.Versioning.TargetPlatformAttribute("Windows7.0")] | ||
[assembly: System.Runtime.Versioning.SupportedOSPlatformAttribute("Windows7.0")] | ||
|
||
// Vygenerované třídou WriteCodeFragment nástroje MSBuild | ||
|
1 change: 1 addition & 0 deletions
1
...auncherPlugin/obj/Debug/Flow.Launcher.Plugin.UnityLauncherPlugin.AssemblyInfoInputs.cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
e92dfd832dcc9ac966b62ab52dafc193fc15ceb62d3e0f8af67fd8a269d7d5e3 |
16 changes: 16 additions & 0 deletions
16
.../Debug/Flow.Launcher.Plugin.UnityLauncherPlugin.GeneratedMSBuildEditorConfig.editorconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
is_global = true | ||
build_property.TargetFramework = net7.0-windows | ||
build_property.TargetPlatformMinVersion = 7.0 | ||
build_property.UsingMicrosoftNETSdkWeb = | ||
build_property.ProjectTypeGuids = | ||
build_property.InvariantGlobalization = | ||
build_property.PlatformNeutralAssembly = | ||
build_property.EnforceExtendedAnalyzerRules = | ||
build_property._SupportedPlatformList = Linux,macOS,Windows | ||
build_property.RootNamespace = Flow.Launcher.Plugin.UnityLauncherPlugin | ||
build_property.ProjectDir = D:\Uzivatel\Admin\Dokumenty\Flow launcher plugins\UnityLauncherPlugin\UnityLauncherPlugin\Flow.Launcher.Plugin.UnityLauncherPlugin\ | ||
build_property.EnableComHosting = | ||
build_property.EnableGeneratedComInterfaceComImportInterop = | ||
build_property.CsWinRTUseWindowsUIXamlProjections = false | ||
build_property.EffectiveAnalysisLevelStyle = 7.0 | ||
build_property.EnableCodeStyleSeverity = |
Binary file added
BIN
+1.98 KB
...lugin.UnityLauncherPlugin/obj/Debug/Flow.Launcher.Plugin.UnityLauncherPlugin.assets.cache
Binary file not shown.
93 changes: 93 additions & 0 deletions
93
...UnityLauncherPlugin/obj/Flow.Launcher.Plugin.UnityLauncherPlugin.csproj.nuget.dgspec.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
{ | ||
"format": 1, | ||
"restore": { | ||
"D:\\Uzivatel\\Admin\\Dokumenty\\Flow launcher plugins\\UnityLauncherPlugin\\UnityLauncherPlugin\\Flow.Launcher.Plugin.UnityLauncherPlugin\\Flow.Launcher.Plugin.UnityLauncherPlugin.csproj": {} | ||
}, | ||
"projects": { | ||
"D:\\Uzivatel\\Admin\\Dokumenty\\Flow launcher plugins\\UnityLauncherPlugin\\UnityLauncherPlugin\\Flow.Launcher.Plugin.UnityLauncherPlugin\\Flow.Launcher.Plugin.UnityLauncherPlugin.csproj": { | ||
"version": "1.0.0", | ||
"restore": { | ||
"projectUniqueName": "D:\\Uzivatel\\Admin\\Dokumenty\\Flow launcher plugins\\UnityLauncherPlugin\\UnityLauncherPlugin\\Flow.Launcher.Plugin.UnityLauncherPlugin\\Flow.Launcher.Plugin.UnityLauncherPlugin.csproj", | ||
"projectName": "Flow.Launcher.Plugin.UnityLauncherPlugin", | ||
"projectPath": "D:\\Uzivatel\\Admin\\Dokumenty\\Flow launcher plugins\\UnityLauncherPlugin\\UnityLauncherPlugin\\Flow.Launcher.Plugin.UnityLauncherPlugin\\Flow.Launcher.Plugin.UnityLauncherPlugin.csproj", | ||
"packagesPath": "C:\\Users\\Admin\\.nuget\\packages\\", | ||
"outputPath": "D:\\Uzivatel\\Admin\\Dokumenty\\Flow launcher plugins\\UnityLauncherPlugin\\UnityLauncherPlugin\\Flow.Launcher.Plugin.UnityLauncherPlugin\\obj\\", | ||
"projectStyle": "PackageReference", | ||
"fallbackFolders": [ | ||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages" | ||
], | ||
"configFilePaths": [ | ||
"C:\\Users\\Admin\\AppData\\Roaming\\NuGet\\NuGet.Config", | ||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config", | ||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" | ||
], | ||
"originalTargetFrameworks": [ | ||
"net7.0-windows" | ||
], | ||
"sources": { | ||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, | ||
"https://api.nuget.org/v3/index.json": {} | ||
}, | ||
"frameworks": { | ||
"net7.0-windows7.0": { | ||
"targetAlias": "net7.0-windows", | ||
"projectReferences": {} | ||
} | ||
}, | ||
"warningProperties": { | ||
"warnAsError": [ | ||
"NU1605" | ||
] | ||
}, | ||
"restoreAuditProperties": { | ||
"enableAudit": "true", | ||
"auditLevel": "low", | ||
"auditMode": "direct" | ||
}, | ||
"SdkAnalysisLevel": "9.0.100" | ||
}, | ||
"frameworks": { | ||
"net7.0-windows7.0": { | ||
"targetAlias": "net7.0-windows", | ||
"dependencies": { | ||
"Flow.Launcher.Plugin": { | ||
"target": "Package", | ||
"version": "[4.4.0, )" | ||
} | ||
}, | ||
"imports": [ | ||
"net461", | ||
"net462", | ||
"net47", | ||
"net471", | ||
"net472", | ||
"net48", | ||
"net481" | ||
], | ||
"assetTargetFallback": true, | ||
"warn": true, | ||
"downloadDependencies": [ | ||
{ | ||
"name": "Microsoft.AspNetCore.App.Ref", | ||
"version": "[7.0.20, 7.0.20]" | ||
}, | ||
{ | ||
"name": "Microsoft.NETCore.App.Ref", | ||
"version": "[7.0.20, 7.0.20]" | ||
}, | ||
{ | ||
"name": "Microsoft.WindowsDesktop.App.Ref", | ||
"version": "[7.0.20, 7.0.20]" | ||
} | ||
], | ||
"frameworkReferences": { | ||
"Microsoft.NETCore.App": { | ||
"privateAssets": "all" | ||
} | ||
}, | ||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.101\\RuntimeIdentifierGraph.json" | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.