With this code, based on a number of dynamically created buttons, I create as many toggles.
The buttons, if pressed, make the corresponding toggle true, and with these bools I perform some checks.
Usually the toggles can be registered by the animation tool,
however this toggle array is not animatable.
Did I do something wrong?
public void GenerateToggleList(UMoodTool.relativeBool[] backBoolList, Toggle[] toggleList)
{
VisualElement BoolContainer = m_node.Q<VisualElement>("BoolContainer");
toggleList = new Toggle[backBoolList.Length];
SerializedProperty array = serializedObject.FindProperty("arrayBoolEyesbrown");
for(int i = 0; i < array.arraySize; i++)
{
serializedObject.Update();
Toggle myToggle = new Toggle();
toggleList[i] = myToggle;
toggleList[i].label = backBoolList[i].relative_Name;
var element = array.GetArrayElementAtIndex(i).FindPropertyRelative("relative_Bool");
toggleList[i].BindProperty(element);
BoolContainer.Add(toggleList[i]);
serializedObject.ApplyModifiedProperties();
}
}