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

Lists of Enums that are assigned values through the editor have incorrect values at runtime #52175

Closed
491625 opened this issue Aug 28, 2021 · 1 comment

Comments

@491625
Copy link

491625 commented Aug 28, 2021

Godot version

3.3.3

System information

Windows 10

Issue description

I have a list of enum values that is exposed through the editor via the [Export] attribute. At runtime, the first entry in that list has an incorrect value that doesn't correspond to any member of the enum.

I've repro'd the problem in a stripped down project that only contains the following script assigned to a single Node2D.

using Godot;
using System;
using System.Collections.Generic;

public class NodeWithEnumList : Node2D
{
	
	[Export]
	public List<TestEnum> EnumVals {get; set;}
	
	// Called when the node enters the scene tree for the first time.
	public override void _Ready()
	{
		foreach(var enumVal in EnumVals)
		{
			Console.WriteLine($"You have an enumVal of {enumVal}");
		}
	}

	public enum TestEnum
	{
		firstVal,
		secondVal
	}

}

Here's what's configured for that Node2D in the editor.
image

And here's what gets printed out in the console.
image

Steps to reproduce

Repro steps are included in the 'Issue Description' above, but here's a quick summary of how to repro with the project attached.

  1. Start up the project and make sure that the 'Enum Vals' property on the Node2D has at least 1 entry assigned to it.
  2. Play the project (you may want to have a debugger attached and a breakpoint in the _Ready() function in NodeWithEnumList.cs)
  3. Look at the console output, or use the debugger to inspect the value of the EnumVals variable.

Minimal reproduction project

EnumBugTest.zip

@Calinou
Copy link
Member

Calinou commented Aug 28, 2021

Duplicate of #42926.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants