Add optional location for Plugin Icon to be inside plugin project root

This commit is contained in:
Wojtek Figat
2021-07-21 11:49:11 +02:00
parent 99eb3447ef
commit 5a6853ba32
2 changed files with 16 additions and 5 deletions

View File

@@ -28,12 +28,24 @@ namespace FlaxEditor
var assemblyName = assembly.GetName().Name;
var dotEditorPos = assemblyName.LastIndexOf(".Editor", StringComparison.OrdinalIgnoreCase);
if (dotEditorPos != -1)
assemblyName = assemblyName.Substring(dotEditorPos);
var iconPath = Path.Combine(Path.GetDirectoryName(assemblyPath), assemblyName + ".Icon.flax");
assemblyName = assemblyName.Substring(0, dotEditorPos);
var dotCSharpPos = assemblyName.LastIndexOf(".CSharp", StringComparison.OrdinalIgnoreCase);
if (dotCSharpPos != -1)
assemblyName = assemblyName.Substring(0, dotCSharpPos);
var assemblyDir = Path.GetDirectoryName(assemblyPath);
// Try path relative to the plugin binary
var iconPath = Path.Combine(assemblyDir, assemblyName + ".Icon.flax");
if (!File.Exists(iconPath))
return null;
{
// Try path relative to the plugin project Content
iconPath = Path.Combine(assemblyDir, "../../../../../Content", assemblyName + ".Icon.flax");
MessageBox.Show(StringUtils.NormalizePath(StringUtils.RemovePathRelativeParts(iconPath)));
if (!File.Exists(iconPath))
{
return null;
}
}
return FlaxEngine.Content.LoadAsync<Texture>(iconPath);
}

View File

@@ -189,7 +189,6 @@ namespace FlaxEditor
// Absolute
referencePath = reference.Name;
}
referencePath = StringUtils.RemovePathRelativeParts(referencePath);
// Load referenced project
reference.Project = Load(referencePath);