- Home /
C# DateTime inspector
I have made a few custom classes that need to hold DateTime information. However, DateTime is not one of the data types that show up in the Inspector.
Is it possible for me to somehow code a custom inspector that will then be used anywhere a DateTime is used (even embedded in any of my various custom classes)?
Based on my research so far, it seems like if you code a custom inspector for a class it only works for objects that are that class, not for objects that have an instance of that class. If so, then it looks like I may be out of luck (short of making a custom inspector for every one of my classes that has a DateTime variable). I'm hoping that's not true.
I expect my answer co$$anonymous$$g nearly two years late isn't much use, but here it is ...
Answer by BarryNorthern · Mar 27, 2014 at 03:13 PM
You can use a property drawer for a custom serializable class.
http://docs.unity3d.com/Documentation/Components/editor-PropertyDrawers.html
So if you create your date time class as a serialisable class you can include a variable of that type in as many scripts as you like and the Unity inspector will use the property drawer for it.
Heh, yeah. $$anonymous$$y question was from a time before Unity had property drawers. So, basically, my question was really a feature request that Unity later addressed. But thanks for formalizing the answer for future readers! :)
No worries, I think it's always good to add answers for unanswered questions for other people's reference :)
Answer by Tortuap · Mar 26, 2018 at 05:16 PM
I found this code to be ready for copy/paste and that works like a charm ! https://gist.github.com/EntranceJew/f329f1c6a0c35ac51763455f76b5eb95
Your answer
![](https://koobas.hobune.stream/wayback/20220613070526im_/https://answers.unity.com/themes/thub/images/avi.jpg)