Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by CognitiveVision · Jun 11, 2013 at 09:36 PM · editorclasscustom-inspectordraw

CustomEditor show an instance of a Class inside a Class

This is a question for C#

I've been making a custom editor to make my class a bit more neat int he inspector. Its a lot easier to just make a custom one than to do [HideInInspector] on every property. Besides that I need create some tools in the editor for the class to help me with things. The problem I'm having since I've never used custom editor before and all the documentation seems to just be javascript. Even then, I cant seem to find a solution to my issue.

When you put System.Serializable over a class, it makes the instance of that class inside a class appear in the inspector. I need this. However when I make a custom inspector I cant find any way to have the class drawn in. There is a EditorGUILayout field for almost everything, but none for classes. It would be a lot of work making a custom editor for every class within the class, unnecessarily so, Unity draws it on its on in the default inspector. So shouldn't there be a method to draw it again just like for the other fields?

Here is the first legs of the custom editor. Instead of that DrawDefaultInspector, I'd like a way to make theTarget.theclass appear just as it would in the default inspector.

 public bool Movement;
     
     public override void OnInspectorGUI()
     {
         playerFSM theTarget = ((playerFSM)target);
         
         DrawDefaultInspector();
         
         Movement = EditorGUILayout.Foldout(Movement, "Movement Details");
         if (Movement)
         {
             theTarget.speed = EditorGUILayout.FloatField("    Speed", theTarget.speed);
             theTarget.jumpSpeed = EditorGUILayout.FloatField("    Jump Speed", theTarget.jumpSpeed);
             theTarget.gravity = EditorGUILayout.FloatField("    Gravity", theTarget.gravity);
             theTarget.rayLength = EditorGUILayout.FloatField("    Ray Length", theTarget.rayLength);
         }
         
     }

If this isn't possible that would be nice to know too, so that I know not to waste my time with it. I'd rather just hide inspector on everything I dont want to show, instead of writing a custom editor for the class inside a class with its arrays and things I need drawn in the inspector. xD

Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

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

14 People are following this question.

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

Related Questions

Cloning GameObjects with custom inspector script attached 0 Answers

Update editorscript if gameobject is manipulated. 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Arrays In Classes? 2 Answers

Cross project scripting? 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