Skip to content

Commit 3c0eaec

Browse files
committed
Fix relative paths for global class icons in C#
1 parent da5f398 commit 3c0eaec

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,17 @@ internal static unsafe void GetGlobalClassName(godot_string* scriptPath, godot_s
241241

242242
if (outIconPath != null)
243243
{
244-
var iconAttr = scriptType.GetCustomAttributes(inherit: false)
244+
IconAttribute? iconAttr = scriptType.GetCustomAttributes(inherit: false)
245245
.OfType<IconAttribute>()
246246
.FirstOrDefault();
247247

248-
*outIconPath = Marshaling.ConvertStringToNative(iconAttr?.Path);
248+
if (!string.IsNullOrEmpty(iconAttr?.Path))
249+
{
250+
string iconPath = iconAttr.Path.IsAbsolutePath()
251+
? iconAttr.Path.SimplifyPath()
252+
: scriptPathStr.GetBaseDir().PathJoin(iconAttr.Path).SimplifyPath();
253+
*outIconPath = Marshaling.ConvertStringToNative(iconPath);
254+
}
249255
}
250256

251257
if (outBaseType != null)

0 commit comments

Comments
 (0)