Archive 17/01/2023.

ENUM_ACCESSOR bugged?

TheComet

Hey!

I’m trying to use URHO3D_ENUM_ACCESSOR_ATTRIBUTE but it’s adding an extra item into the dropdown menu that shouldn’t be there. I have the following code:

[code]void IKRoot::RegisterObject(Context* context)
{
context->RegisterFactory(IK_CATEGORY);

static const char* algorithmNames[] = {
    "None",
    "Jacobian Inverse",
    "Jacobian Transpose",
    "FABRIK"
};
URHO3D_ENUM_ACCESSOR_ATTRIBUTE("Algorithm", GetSolverType, SetSolverType, IKSolver::SolverAlgorithm, algorithmNames, IKSolver::FABRIK, AM_DEFAULT);

}[/code]

Where my enum is defined as:

enum SolverAlgorithm { NONE = 0, JACOBIAN_INVERSE, JACOBIAN_TRANSPOSE, FABRIK };

The result is a dropdown menu with 5 items instead of 4:

If I add another string to the array of strings:

static const char* algorithmNames[] = { "None", "Jacobian Inverse", "Jacobian Transpose", "FABRIK", "This shouldn't be here" };

Then the dropdown menu also gains another item, but it’s still one too many:

Is this a bug or am I doing something wrong?

cadaver

You need a terminator null ptr. See e.g. BillboardSet.cpp.

TheComet

Aaah, that makes sense. Thanks a lot!