- Home /
How can I have multiple inspector inside of a custom inspector
Hello all!
I´m having trouble creating a custom inspector and drawing others inspectors based on an array, inside it.
Im able to add new elements to the array and draw the new inspector but the general inspector is not updated instantly
![alt text][1]
The Add button is working but the list is not updated. Same for the remove button ( - )
The ActionGroupBehaviour have an array of actions (type of ScriptableObject):
[SerializeField] private ActionSO[] _actions = new ActionSO[0];
And on the CustomEditor script I iterate over this array and create the editors:
private VisualElement CreateActionsContainer(ActionSO[] actions)
{
VisualElement actionContainer = new VisualElement();
actionContainer.AddToClassList("actions-container");
VisualElement actionInspector = null;
for (int i = 0; i < actions.Length; i++)
{
actionInspector = CreateActionEditor(actions[i]);
actionContainer.Add(actionInspector);
}
return actionContainer;
}
And this is the action executed when the Add button is clicked:
private Action OnActionAdded()
{
return () =>
{
ActionSO newAction = CreateInstance(_selectedAction) as ActionSO;
_actions.AddToObjectArray(newAction);
serializedObject.ApplyModifiedProperties();
};
}
I guess my problem is related to binding the array but I dont know have to address it.
Sorry for my english.
Thanks! [1]: /storage/temp/179363-custominspector.png
Your answer
Follow this Question
Related Questions
How to update value of runtime non-serializable in a custom inspector using UIElements? 0 Answers
Changing First Person Controller key bindings at runtime 0 Answers
calculate things... and display in inspector 3 Answers
How to correctly register Undos in Custom Inspector (within OnInspectorGUI)? 4 Answers
Variable property drawer height effects all in List 4 Answers