Exception when using TabGroup in non Component classes which are shown in Lists with the attribute "NumberOfItemsPerPage = 1"

Issue #213 resolved
Former user created an issue

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;

    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() };

    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)

  1. Log in to comment