Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ResourceUid in C# gives error #74270

Closed
AhNesh opened this issue Mar 3, 2023 · 0 comments · Fixed by #74280
Closed

Using ResourceUid in C# gives error #74270

AhNesh opened this issue Mar 3, 2023 · 0 comments · Fixed by #74280

Comments

@AhNesh
Copy link

AhNesh commented Mar 3, 2023

Godot version

4.0.stable.mono

System information

Windows 10

Issue description

When calling ResourceUid.TextToId(text) or ResourceUid.IdToText(id) in C# it causes this error:

Failed to retrieve non-existent singleton 'ResourceUid'.
  modules/mono/glue/runtime_interop.cpp:1303 - System.ArgumentNullException: Value cannot be null. (Parameter 'ptr')
     at Godot.NativeCalls.godot_icall_1_922(IntPtr method, IntPtr ptr, String arg1) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Generated/NativeCalls.cs:line 8450
     at Godot.ResourceUid.TextToId(String textId) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Generated/GodotObjects/ResourceUid.cs:line 58
     at uidtest.set_Text(String value) in D:\Documents\Repos\Godot\CitrusOrchestra\uidtest.cs:line 14
     at uidtest.SetGodotClassPropertyValue(godot_string_name& name, godot_variant& value) in D:\Documents\Repos\Godot\CitrusOrchestra\Godot.SourceGenerators\Godot.SourceGenerators.ScriptPropertiesGenerator\uidtest_ScriptProperties.generated.cs:line 16
     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 57

Steps to reproduce

Add script below to a node, build, and write some number in the Id property in inspector. See error in output.

Minimal reproduction project

using Godot;
using System;

[Tool]
public partial class uidtest : Node
{
	[Export]
	public string Text
	{
		get => text;
		set
		{
			text = value;
			GD.Print(ResourceUid.TextToId(text));
		}
	}
	
	[Export]
	public long Id
	{
		get => id;
		set
		{
			id = value;
			GD.Print(ResourceUid.IdToText(id));
		}
	}

	private string text;
	private long id;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants