You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For C# Scripts that have a custom property list where one of the properties's hint is HintType.ResourceType and the hint string is the name of the script, attempting to assign it throws an InvalidCastException:
modules/mono/glue/runtime_interop.cpp:1324 - System.InvalidCastException: Unable to cast object of type 'Godot.Resource' to type 'Y'.
at X._Set(StringName property, Variant value)
at Godot.Bridge.CSharpInstanceBridge.Set(IntPtr godotObjectGCHandle, godot_string_name* name, godot_variant* value) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/CSharpInstanceBridge.cs:line 67
Steps to reproduce
Generic Overview
Create a script named Foo.cs
Create a script named Bar.cs
Open the Bar.cs script. Make the base class Resource
Mark Bar as a GlobalClass
Open Foo.cs
Mark Foo as a Tool, and GlobalClass.
Paste the following code inside the class body of Foo:
Tool scripts are instantiated and executed in the editor, but non-Tool scripts are not. Your Bar type is not marked with the [Tool] attribute so the editor can't instantiate it when you assign it to a property of the Tool script Foo.
Add the [Tool] attribute to the Bar type or use a less specific type for the Foo.barRef field (e.g.: Resource).
Godot version
v4.1.2.stable.mono.official [399c9dc]
System information
Windows 10
Issue description
For C# Scripts that have a custom property list where one of the properties's hint is
HintType.ResourceType
and the hint string is the name of the script, attempting to assign it throws an InvalidCastException:Steps to reproduce
Generic Overview
Foo.cs
Bar.cs
Bar.cs
script. Make the base classResource
Bar
as aGlobalClass
Foo.cs
Foo
as aTool
, andGlobalClass
.Foo
:Godot.Collections
Bar
resource in the FileSystemFoo
object in a scene.Bar
tobar_ref
property inFoo
Minimal Reproduction Project
root
scene if not already open.Foo
. If not, add it.Bar Ref
property and assign it tobar
in the FileSystemMinimal reproduction project
project.zip
The text was updated successfully, but these errors were encountered: