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
2
Question by Catlard · Dec 18, 2012 at 10:55 AM · c#editorobjectinspector

Custom objects from editor scripts?

Hey, folks!

So, I've got an object -- called Cat, for example. And I want to display that in the Unity Inspector, with all its variables. Is there an easy way of doing this when you are also attempting to edit how the Inspector works? It seems to work quite easily when you're just plugging them in with [System.Serializable], and not touching the inspector with an Editor script. But when you are, it seems you can't just cause it to appear with its variables when you call object.FindProperty("_catObject");. Have you tried this? How does it work?

Comment
Add comment · Show 3
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 clunk47 · Dec 18, 2012 at 08:22 PM 1
Share

Not sure what you mean. IF you mean a Class named Cat with some variables in C#, just make a public class w/ public variables like so:

 using UnityEngine;
 using System.Collections;
 
 public class Cat : $$anonymous$$onoBehaviour
 {
     public float testFloat = 1.0f;
     public string testString = "cat";
     public int testInt = 1;
     public GameObject testGameObject;
     public Transform testTransform;

     void start()
     {
 
     }

     void Update()
     {
 
     }
 }
avatar image Catlard clunk47 · Dec 18, 2012 at 11:14 PM 1
Share

Sorry, I meant when you declare them and want them to be editable in a script that modifies the inspector window! Thanks, though.

avatar image clunk47 clunk47 · Dec 18, 2012 at 11:45 PM 1
Share

Oh sry lol XD

I voted your question up as well as the accepted answer because I learned something new, thanks :)

1 Reply

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

Answer by Loius · Dec 18, 2012 at 05:51 PM

If in your InspectorGUI function you use "DrawDefaultInspector()", that will do the default inspector for the object. You can "[HideInInspector]" any public variables you don't want to show up in that, and it'll draw the default inspector for your subclasses.

Comment
Add comment · Show 1 · 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 Catlard · Dec 18, 2012 at 11:13 PM 1
Share

This is the answer I was looking for! Thanks, I'll check it out.

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

11 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

Related Questions

ReImport in c# of GameObjects only for Scene Objects, not assets? 1 Answer

TexturePropertySingleLine in Editor class 0 Answers

Editor Script, Index Out of Range Exception after Play 1 Answer

Gizmos.DrawLine is dissapearing after returning to editor after Playing the scene 0 Answers

Change position using custom and native editor 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