godotengine / godotengine/godot
Errors of custom resources in C# for Godot
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
4.4.stable.mono
### System information
Godot v4.4.stable.mono - Windows 11 (build 26100) - Multi-window, 2 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 Ti (NVIDIA; 32.0.15.6109) - 13th Gen Intel(R) Core(TM) i5-13600K (20 threads)
### Issue description
```
using Godot;
using System;
[GlobalClass]public partial class CResource : Resource
{
private Vector2 _position = new(40,20);
[Export]public Vector2 Position
{
get => _position;
set => _position = value;
}
}
```
In this code, I set a variable named _position, and this variable can be modified freely.
To verify my data, I created the following code.
```
using Godot;
public partial class C : Node
{
public static CResource CResource1 = GD.Load("uid://jycnevj23t5e");
public static CResource CResource2 = GD.Load("uid://dqq0kpcwbrrwj");
public override void _Ready()
{
GD.Print("You can modify this part.");
GD.Print("My CResource1 is (40,20)");
GD.Print("My CResource1 is (42,42)");
GD.Print(CResource1.Position);
GD.Print(CResource2.Position);
}
}
```

When I modify it, the editor displays normally, but the output value is incorrect.

After restarting Godot, the output value in the editor becomes the printed value.
Currently, I have only encountered this situation in the resources.
### Steps to reproduce
Reset the resource data, then modify _position and run to get the output.
```
[GlobalClass]public partial class CResource : Resource
{
private Vector2 _position = new(40,20);
[Export]public Vector2 Position
{
get => _position;
set => _position = value;
}
}
```
Restarting the project will cause the bug to appear to be normal.
In my tests, the problem does not occur in GDScript.
### Minimal reproduction project (MRP)
[C.zip](https://github.com/user-attachments/files/19333667/C.zip)
Contributor guide
Research direction
Start by running the attached C.zip minimal reproduction with Godot 4.4.stable.mono and compare the editor values with the printed runtime values before and after restarting. Trace the C# custom Resource and exported-property handling implicated by the reproduction. Done means the saved resource values and runtime output agree without requiring a restart.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, godot
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100