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 12, 2011 at 01:23 AM · editorassetsettingscustompersist

Editor Window with settings and Asset Creation

Hi There

Is it possible to create an editor window that has some persistent settings that can then be used to create a new asset or modify an existing one?

My use case is that I am autogenerating some items in my RPG and previously I was doing this externally in a little c# console app that created a csv file and then I was using an editor menu script to read the csv and create and modify a List of item definitions on the selected unity object (containing the appropriate script). I'd rather make the items within unity as part of of an editor window and have some settings that I can modify that change the way in which the items are created. I then want that item setting data to persist between sessions.

I'm also toying with the EditorWindow creating a custom asset - maybe some XML - that I could then load at runtime.

I've been trying to use ScriptableObjects for my item generated data but I can't get the UI to autogenerate for these scripts, I also don't know whether they will persist (but I could probably write some XML out and read it back in). The added complexity here is that I need an array of objects, each object containing parameters for a set of objects I want to generate at the push of a button!

Presumably this kind of scenario can easily be solved and has to be solved for many extensions to the editor?

Thanks in advance! 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
3
Best Answer

Answer by Bovine · Aug 31, 2011 at 07:57 AM

So my solution to this was to:

  1. Create a class subclassing SciptableObject for the editor data

  2. Create an EditorWindow subclassing EditorWindow

  3. In the static Init() method to Get/Create the window I checked for the existence of my EditorData and load if present or create if not

  4. Used EditorGUI.Popups to display the elements I could edit from the various Lists within my EditorData

  5. Displayed GUI below each Popup for the content of the selected item in the popup

  6. Continued with more EditorGUI.Popups and GUI below for detail (master/detail really)

  7. Buttons to add/edit/rename bits of EditorData

  8. A button to create the in-game asset, also a subclassed ScriptableObject

The above took me the best part of a day and I ended up with the image posted at the end.

However, I found this very painful to make, taking a day, and having worked with ScriptableObject subclasses I then elected to do the following:

  1. For the same EditorData subclass of ScriptableObject, I created an Editor subclass

  2. In OnInspectorGUI() I called the base method...

  3. ...I then added GUI for a button to generate the in-game data

  4. I Added a menu item to create the EditorData

  5. I deleted the original editor

This gives me List editing just as I would get for any serialisable object as a public member of a script attached to a GameObject within Unity. It is perhaps not as elegant as the master detail scenario, but it took me about an hour or so to get it working and I wasn't somewhat confused about how to style things.

I think for more advanced editing, that the EditorWindow might have some benefit, but the Editor solution is quicker to code and provides a very usable view of the data.

I hope this information helps someone else who wishes to have EditorData and generate real game data from that.

Item Generation Editor Window

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 Nachtmahr · May 30, 2013 at 10:23 PM 0
Share

$$anonymous$$hh Nice and clean. Is there a source of the Editor / EditorWindow around?

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Unity editor and inspector header 0 Answers

Custom Asset Icons? 2 Answers

Export Settings or custom files to release builds 1 Answer

Gibt es eine Lösung/Einstellung für: Hierarchy Custom / My Sort? 1 Answer

Custom Editor: show asset folders in ObjectField 2 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