Skip to content

Godot.Collections.Dictionary Returns Null for GodotObject-Derived Value Types at Runtime #1125

@Weiged

Description

@Weiged

Tested versions

  • Reproducible in: v4.4.stable.mono.official [e36cb51]

System information

Redot v4.4.stable.mono - macOS Unknown (26.2.0) - Multi-window, 2 monitors - Metal (Forward+) - integrated Apple M4 (Apple9) - Apple M4 (10 threads)

Issue description

When using Godot.Collections.Dictionary<string, T> where T is a class that inherits from GodotObject (such as Container), the dictionary returns null values at runtime even though the values are properly set in the Redot editor.

Expected behavior:
The dictionary should return the actual Container objects that were assigned in the editor. The output should display the container objects with their proper string representations.

Example expected output:

container1: Container:<Container#12345>
container2: Container:<Container#67890>

Actual behavior:
The dictionary returns null for all values, even though the keys are present and the values were set in the editor.

Actual output:

container1: null
container2: null

Additional context:

  • The issue specifically occurs when the value type T in Dictionary<string, T> is a class that inherits from GodotObject
  • The keys in the dictionary are accessible and correct
  • Only the values are returning null
  • This appears to be a serialization/deserialization issue with GodotObject-derived types in dictionaries

Steps to reproduce

  1. Create a C# script that inherits from a Godot node (e.g., Control)
  2. Add an exported field of type Godot.Collections.Dictionary<string, Container> where Container is a class inheriting from GodotObject
  3. Populate the dictionary in the Redot editor with key-value pairs
  4. Access the dictionary values at runtime in the _Ready() method
  5. Observe that the values are null instead of the expected Container objects

Code example:

using Godot;

public partial class TestGodotDictionary : Control
{
	[Export] private Godot.Collections.Dictionary<string, Container> _containers;

	// Called when the node enters the scene tree for the first time.
	public override void _Ready()
	{
		foreach (var container in _containers)
		{
			GD.Print($"{container.Key}: {(container.Value == null ? "null" : container.Value.ToString())}");
		}
	}
}

Minimal reproduction project (MRP)

godotdictionaryreturnnull_2025-12-22_16-45-28.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Open

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions