Hello,
In a ShaderData
, I am using GetDDescription()
to add elements to a LONG CYCLE
description using this code:
struct CycleElementData
{
Int32 elementId; ///< Element id
maxon::String name; ///< Element name
/// \brief Construct from element ID and name
CycleElementData(Int32 t_elementId, const maxon::String& t_name) : elementId(t_elementId), name(t_name)
{}
/// \brief Copy constuctor
CycleElementData(const CycleElementData& src) : elementId(src.elementId), name(src.name)
{}
};
Bool AddCycleElements(GeListNode* node, Description* descr, Int32 myDescId, maxon::BaseArray<CycleElementData>& elements, Bool addSeparator)
{
const DescID* const singleId = descr->GetSingleDescID();
if (IsSingleID(myDescId, singleId))
{
BaseContainer* descSettings = descr->GetParameterI(myDescId, nullptr);
if (!descSettings)
return false;
// Build BaseContainer with cycle elements
BaseContainer cycleElements = descSettings->GetContainer(DESC_CYCLE);
if (addSeparator)
cycleElements.SetString(-1, ""_s);
for (maxon::BaseArray<CycleElementData>::ConstIterator it = elements.Begin(); it != elements.End(); ++it)
{
const CycleElementData& currentElement = *it;
cycleElements.SetString(currentElement.elementId, currentElement.name);
}
descSettings->SetContainer(DESC_CYCLE, cycleElements);
return true;
}
return true;
}
// Later...
maxon::BaseArray<CycleElementData> shaderModes;
shaderModes.Append(CycleElementData(123456, "Some mode"_s)) iferr_ignore();
shaderModes.Append(CycleElementData(654321, "Some other mode"_s)) iferr_ignore();
AddCycleElements(node, description, MYSHADER_MODES, shaderModes, true);
So far, it seems to work fine. The additional entries appear in the LONG CYCLE
in the shader's UI. I can also select them, and it works.
However, when I save the scene, and then load it again, nothing is selected in the LONG CYCLE
. I have to re-select the desired entry again. I guess, this is because the additional entries don't exist yet, when the scene is loaded, and are added later when the shader's GetDDescription()
is called. So what might be the solution?
Greetings & thanks in advance for help,
Frank