Skip to content

C#: Color default assignement is not the same as in GDScript #110361

@GabCoolDude

Description

@GabCoolDude

Tested versions

4.5.rc1.mono, 4.4.stable.mono

System information

Godot v4.5.rc1.mono - Windows 11 (build 26100) - Multi-window, 2 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 (NVIDIA; 32.0.15.7688) - 12th Gen Intel(R) Core(TM) i5-12600KF (16 threads) - 31.81 GiB memory

Issue description

When creating a Color property and leaving it with the default assignment in C#, its values will default to (0, 0, 0, 0). This is not the same behavior as in GDScript, which will default to (0, 0, 0, 1).

[Export] public Color ColorCSharpBugged; // Will create a new Color with these RGB value: (0, 0, 0, 0), not the same as in GDScript
[Export] public Color ColorCSharpNotBugged = new (0,0,0); // Will create a new Color with these RGB value: (0, 0, 0, 1), same as in GDScript

Steps to reproduce

Create a new C# Script
Put a property of type Color and leave it with the default assignment
Print it out or export it

Minimal reproduction project (MRP)

color-default-assignment-csharp-mrp.zip

Click on "new_resource_cs.tres" to see the bug in action
ResourceScriptCSharp.cs is the script of the resource

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions