Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Bovine · Aug 11, 2011 at 01:44 PM · guieditor-scriptingeditorwindow

Edit an object in UnityEditor EditorWindow

Hi All

If I have a class I have created with public members and I have my own EditorWindow. Can I create some GUI to edit the members on that class in the EditorWindow in a similar way to the GUI the editor generates for scripts attached to the selected GameObject automatically, or do I need to create the GUI manually for each property.

I can see PropertyField and ObjectField GUI elements, but it's not entirely clear how these should work.

Thanks H

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

1 Reply

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

Answer by Statement · Aug 11, 2011 at 03:52 PM

Yes you can. Check out the docs for the SerializedProperty which has an example. I am sure you can use this in EditorWindow.OnGUI as well for your window.

Basically you create a SerializedObject from any object, then you can get the SerializedProperty you wish to obtain and use them in EditorGUI.PropertyField or EditorGUILayout.PropertyField.

Comment
Add comment · Show 7 · 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 Bovine · Aug 11, 2011 at 03:59 PM 0
Share

Thanks, I'll check it out - I've been looking at these but not quite got my head around them. At least I know am broadly looking in the right area. Do these classes need to operate on current selection?

avatar image Bovine · Aug 11, 2011 at 09:41 PM 0
Share

I've been using this this evening, but it seems I have to create a PropertyField for each property in my class. I was hoping this framework would create GUI for all public members, if it should, what am I missing?

avatar image Statement · Aug 12, 2011 at 08:27 AM 1
Share

Well, check out http://unity3d.com/support/documentation/ScriptReference/SerializedObject.GetIterator.html - from what I gather of it, it would be used in a foreach, where you get a SerializedProperty for every propery on the object.

avatar image Bovine · Aug 12, 2011 at 08:37 AM 0
Share

Ahh that's pretty useful. I have another snag in that one of my properties is a List of serialisable objects that are subclasses of ScriptableObject but while the List shows up and I can expand or contract it, none of the items in the list show up?

Do I need to create a custom editor for each object? It seems odd, because any ScriptableObject I've exposed on a script would just get UI built for it... ?

avatar image Statement · Aug 12, 2011 at 11:00 AM 0
Share

Well, you could always roll your own code with reflection. something like yourObject.GetType().GetProperties(). Google for ".net Reflection" or something if you want to go this route. This isn't anything unity specific, it's included in .net (and mono)

Show more comments

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How do I get a reference to the default editor windows (Hierarchy, Console, and Inspector)? 1 Answer

Editor GUI Foldout header style customization 0 Answers

Issue with custom editor window zooming feature 0 Answers

Is it possible to store and display EditorGUILayout.Toggles? 0 Answers

How do I make a progress bar in the editor lock the background? 0 Answers


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