Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by casimps1 · Apr 19, 2012 at 07:26 PM · inspectorcustom-inspectordatetime

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.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image BarryNorthern · Mar 27, 2014 at 03:13 PM 0
Share

I expect my answer co$$anonymous$$g nearly two years late isn't much use, but here it is ...

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image casimps1 · Mar 27, 2014 at 03:23 PM 0
Share

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! :)

avatar image BarryNorthern · Mar 27, 2014 at 03:25 PM 0
Share

No worries, I think it's always good to add answers for unanswered questions for other people's reference :)

avatar image
2

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

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image douglassophies · Nov 27, 2021 at 12:07 PM 0
Share

Can you post a working link?

avatar image Tortuap douglassophies · Nov 27, 2021 at 02:24 PM 0
Share

I edited my answer with the direct link.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Implementing a 2D array as a field on a ScriptableObject? 1 Answer

Edit existing editor inspector? 1 Answer

Custom inspector size problem 1 Answer

Static variables assigned in the inspector 2 Answers

How to assign a rigidbody in custom inspector? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges