Closed 31 closed 3 years ago
Ended up with:
public partial class DemoEnumData
{
private static readonly DemoEnumData
A = new DemoEnumData
{
Extended = "AaaaaAAaaAAAAA"
},
B = new DemoEnumData
{
Extended = "BbbbbBbbbbbb"
};
public string Extended { get; private set; }
}
public partial class DemoEnumData
{
public static DemoEnumData Get(DemoEnum key)
{
switch (key)
{
case DemoEnum.A: return A;
case DemoEnum.B: return B;
}
throw new ArgumentOutOfRangeException("key");
}
}
public enum DemoEnum
{
A,
B,
}
public static class DemoEnumExtensions
{
public static DemoEnumData GetData(this DemoEnum v) => DemoEnumData.Get(v);
}
This isn't really OnReady functionality... but I've seen this asked about twice before and it ties into the Godot limitation where the only way you can export a set of options to show up in the editor is via
enum
(or I suppose an editor plugin).From the data definitions:
Generate a lookup and enum:
This way you can
[Export] Tag Foo
to give the scene editor a choice between several options, with an easy (and efficient) way to attach more data to each of those options.