Custom Drawer for DateTime

Issue #199 resolved
Steamroller Studios created an issue

I get the following warning in the inspector:

"There is no custom drawer defined for type 'DateTime', and the type has no members to draw."

I tried to create a Unity property drawer for it but it didn't seem to pick it up.

Is this something that you guys need to do on your side, or is there documentation for creating our own drawers?

Comments (2)

  1. Steamroller Studios reporter

    Never mind, I figured it out since you guys ship some examples in your package.

    Just in case anyone runs into this questions, here is a real quick implementation of the DataTimeDrawer:

    using System;
    using System.Globalization;
    using UnityEngine;
    using UnityEditor;
    using Sirenix.OdinInspector.Editor;
    [ OdinDrawer ]
    public class DateTimeDrawer : OdinValueDrawer<DateTime>
        protected override void DrawPropertyLayout( IPropertyValueEntry<DateTime> entry, GUIContent label )
            var _dateTime = entry.SmartValue;
            var _rect = EditorGUILayout.GetControlRect();
            if( label != null )
                _rect = EditorGUI.PrefixLabel( _rect, label );
            var _result = EditorGUI.TextField( _rect, _dateTime.ToString( "o" ) );
            if( DateTime.TryParse( _result, null, DateTimeStyles.RoundtripKind, out _dateTime ) )
                entry.SmartValue = _dateTime;
  2. Log in to comment