Dictionary - key and value are not initialized properly in add popup for their OdinValueDrawer

Issue #793 open
Maciej Paluszek created an issue

When dictionary add popup is opened key and value are not properly initialized when Initialize is called in their OdinValueDrawer. It is problematic when references to child InspectorPropertyare created in Initialize.

public class TestContainer
    private float m_test;

private Dictionary<TestContainer, float> m_dictionary = new Dictionary<TestContainer, float>();

using Sirenix.OdinInspector.Editor;
using UnityEngine;

namespace Script.Editor
    public class TestContainerDrawer : OdinValueDrawer<Test.TestContainer>
        private InspectorProperty m_child;

        protected override void Initialize()

            m_child = Property.Children["m_test"];

        protected override void DrawPropertyLayout(GUIContent label)

Comments (2)

  1. Tor Esa Vestergaard

    This does not seem to be an error, but rather a consequence of TestContainer being null by default as it's a class, and therefore the assumption that it has child values cannot be made because the value is (correctly) null at the time of initialization, and so there are no children.

    If I've misunderstood this case, please feel free to re-open the issue with further clarifications or examples.

  2. Maciej Paluszek reporter
    • changed status to open

    I understand this assumption, but in your tutorial https://www.youtube.com/watch?v=06_giCwo2u4 you show to create reference to child properties in Initialize.

    So you eighter have to change this assumption and chande code or update tutorials to teach correct way to create refecences to child properties.

  3. Log in to comment