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 bruce965 · Feb 13, 2013 at 03:02 PM · c#editorwindowstatic

EditorWindow properties in Game Code

Brief description

Is it possible to expose EditorWindow properties (automatically serialized by Unity) so that they can be accessed in Game Code when compiled? Thanks


Full description

I have created a custom editor for a list of items...

alt text

 public class ItemsEditor : EditorWindow
 {
     public List<ItemDescriptor> Items = new List<ItemDescriptor>();
     // Other code...
 }

I would like to copy this list in a publicly accessible static variable when running the game or compiling, but I couldn't find any way to do so...

Can you help me?

Thanks, Fabio Iotti

itemsview.png (11.4 kB)
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
1
Best Answer

Answer by Jessy · Feb 13, 2013 at 03:39 PM

You can't access anything that's stored in an Editor window. It's for the Editor, not the build. Instead, store the data in Scriptable Objects in your project, and read from those objects, to the window. (Or, if you prefer, just use a custom Inspector for the Scriptable Object.) MonoBeaviours can reference Scriptable Objects.

Comment
Add comment · Show 4 · 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 bruce965 · Feb 13, 2013 at 03:52 PM 0
Share

I didn't know of ScriptableObject(s), thanks a lot!

avatar image bruce965 · Feb 13, 2013 at 05:50 PM 0
Share

Ok, I tried using a ScriptableObject as you suggested, but this time I failed to create a serialized singleton (avoiding to create an asset), any advice? Thanks again...

avatar image Jessy · Feb 13, 2013 at 06:42 PM 0
Share

Posting your code would help. But know that a ScriptableObject either needs to be an asset, or referenced by something in a scene. In the latter case, it is serialized with the scene only.

avatar image bruce965 · Feb 13, 2013 at 07:03 PM 0
Share

To simplify it, I need a static List, serializing with the scene would be perfect, it should be referenced by both EditorWindow and $$anonymous$$onoBehaviour classes.

If it help, I'll post the code.

Really thanks for your availability.

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

10 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How do I have an EditorWindow save it's data inbetween opening and closing Unity? C# 5 Answers

Calling non-static from static function C# 2 Answers

Custom Editor Window not opening after layout crash 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