-
assigned issue to
Exception when using TabGroup in non Component classes which are shown in Lists with the attribute "NumberOfItemsPerPage = 1"
Issue #213
resolved
As the title say when using the TabGroup attribute in non Component classes which are shown in a List with the attribute ListDrawerSettings with the property value "NumberOfItemsPerPage = 1", the following exception is shown:
Exception: Tabs must be registered in Layout first.
Sample code:
using UnityEngine;
using System.Collections.Generic;
using Sirenix.OdinInspector;
public class ExceptionSample : MonoBehaviour
{
[ListDrawerSettings(NumberOfItemsPerPage = 1)]
public List<MyClassA> list;
[OnInspectorGUI]
private void ListInitializer()
{
if (Event.current.type == EventType.Repaint)
if (list == null || list.Count == 0)
list = new List<MyClassA>() { new MyClassA(), new MyClassA(), new MyClassA() };
}
[System.Serializable]
public class MyClassA
{
[TabGroup("Tab 1")]
public string prop1;
[TabGroup("Tab 1")]
public string prop2;
}
}
P.S. the if check to event type inside the OnInspectorGUI method
if (Event.current.type == EventType.Repaint)
is needed to avoid another exception: ArgumentException: Getting control 4's position in a group with only 4 controls when doing repaint
Comments (2)
-
-
- changed status to resolved
- Log in to comment