From 8240e27636543898c058cf1f5e1dad196f913361 Mon Sep 17 00:00:00 2001 From: DE YU <71481700+Delsin-Yu@users.noreply.github.com> Date: Wed, 25 Sep 2024 19:07:22 +0800 Subject: [PATCH] Implement Reminder for External Node Types --- .../Inspector/ExternalTypeReminder.cs | 35 +++++++++++++++++++ .../GodotTools/Inspector/InspectorPlugin.cs | 6 ++-- .../Core/Bridge/ScriptManagerBridge.cs | 1 - 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 modules/mono/editor/GodotTools/GodotTools/Inspector/ExternalTypeReminder.cs diff --git a/modules/mono/editor/GodotTools/GodotTools/Inspector/ExternalTypeReminder.cs b/modules/mono/editor/GodotTools/GodotTools/Inspector/ExternalTypeReminder.cs new file mode 100644 index 00000000000..71ca3d61835 --- /dev/null +++ b/modules/mono/editor/GodotTools/GodotTools/Inspector/ExternalTypeReminder.cs @@ -0,0 +1,35 @@ +using Godot; +using GodotTools.Internals; + +namespace GodotTools.Inspector; + +public partial class ExternalTypeReminder : HBoxContainer +{ + public override void _Ready() + { + SetAnchorsPreset(LayoutPreset.TopWide); + + var iconTexture = GetThemeIcon("NodeInfo", "EditorIcons"); + + var icon = new TextureRect() + { + Texture = iconTexture, + ExpandMode = TextureRect.ExpandModeEnum.FitWidthProportional, + CustomMinimumSize = iconTexture.GetSize(), + }; + + icon.SizeFlagsVertical = SizeFlags.ShrinkCenter; + + var label = new Label() + { + Text = "This inspector inherits an external type. Please build the C# project when the external type changes.".TTR(), + AutowrapMode = TextServer.AutowrapMode.WordSmart, + CustomMinimumSize = new Vector2(100f, 0f), + }; + + label.SizeFlagsHorizontal = SizeFlags.Fill | SizeFlags.Expand; + + AddChild(icon); + AddChild(label); + } +} diff --git a/modules/mono/editor/GodotTools/GodotTools/Inspector/InspectorPlugin.cs b/modules/mono/editor/GodotTools/GodotTools/Inspector/InspectorPlugin.cs index 8aeb19e08b7..074e739b248 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Inspector/InspectorPlugin.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Inspector/InspectorPlugin.cs @@ -31,9 +31,9 @@ namespace GodotTools.Inspector if (string.IsNullOrEmpty(scriptPath)) { - // Generic types used empty paths in older versions of Godot - // so we assume your project is out of sync. - AddCustomControl(new InspectorOutOfSyncWarning()); + // Types from an external source (PackageReference or ProjectReference) + // uses empty paths, in such case we do not show out of sync warning. + AddCustomControl(new ExternalTypeReminder()); break; } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs index 91d49854c73..8201d3f1343 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs @@ -217,7 +217,6 @@ namespace Godot.Bridge // not a global class. But if the script is not a global class it must return an empty // outClassName string since it should not have a name. string scriptPathStr = Marshaling.ConvertStringToManaged(*scriptPath); - Debug.Assert(!string.IsNullOrEmpty(scriptPathStr), "Script path can't be empty."); if (!_pathTypeBiMap.TryGetScriptType(scriptPathStr, out Type? scriptType)) {