Binding of enum


I wonder what’s the best practice to binding c++ enum?

As I’m binding all UE4 enum to SkookumScript Enum class, I found it’s a little ugly to write sth. like:

KismetMathLibrary.ease(0, 10, 0.5, Enum!int(0), 0, 10)

Not to mention the hardcoded enum value also make it error prone as the enum order could be easily changed in c++ side.

One solution is generating Enum subclass, and add enum value as class member of generated Enum subclass, like: SomeEnumType.@SomeEnumVal, but I wonder if that’s the recommend way to go or there’ll be language feature support planned regarding enum in SkookumScript?


Yes, in previous titles using SkookumScript the C++ enums were often created via generated files.

You can see an example in the TestEnum class found in the Core-Sandbox overlay. To enable/disable the Core-Sandbox overlay in the IDE - go to Settings->Project Settings... then select the Core-Sandbox and press the [ ] button.

We will be generating Unreal Engine 4 common enums in a future update.

The current Enum class type is just a temporary mechanism until enumerations become a proper part of the SkookumScript syntax. You can see how the future syntax will look with enum-definition and enumerator in the latest planned syntax file.

With generated enum class, now the code looks like this:
KismetMathLibrary.ease(0, 10, 0.5, EEasingFunc.@@linear, 0, 10)
That’s much better. Thanks, Noolarch!

Btw, I have implemented all necessary logic in SkookumScriptGeneartor to support all UE4 enums. I can submit a PR if you guys not already working on that.