I’m aware that you can do enum attributes like this:
MyScript.attributes.add('myEnum', {
type: 'number',
enum: [
{ 'Something': 1 },
{ 'SomethingElse': 2 },
{ 'SomethingElseAgain': 3 }
],
title: "Some Enum"
});
And that you can also do:
MyScript.MyEnum =
{
Something: 1,
SomethingElse: 2,
SomethignElseAgain: 3
};
Is there a way to combine the two?
(such that the enum can be exposed within the editor and still be referenced in code without having to use ‘magic numbers’.
E.g. something like the following (but this obviously won’t work):
MyScript.attributes.add('myEnum', {
type: 'number',
enum: MyScript.MyEnum,
title: "Some Enum"
});
MyScript.MyEnum =
{
Something: 1,
SomethingElse: 2,
SomethignElseAgain: 3
};
if (someValue == MyScript.MyEnum.Something) { ... }
Wondering if anyone has found a nice solution to this?