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 Snailtan · Jan 23, 2021 at 09:47 AM · editorinspectoreditor-scriptingdatabasedata

Can I make a class editable in the inspector, without having to have a GameObject associated with it?

So I have a simple data class like this:

 [System.Serializable]
 public class Bow
 {
     [SerializeField]
     public Sprite[] AnimationSprites;
 }
 [System.Serializable]
 
 public class TestClass : MonoBehaviour
 {
     [SerializeField]
     private List<Bow> BowSprites = new List<Bow>();
 }

Which when put on some GameObject gives me this: alt text

Now, I want to have a bunch of bows, with attributes n stuff yknow the usual.

So I have a few ways of doing this:

Making a GameObject that holds my data script and reference this everywhere I need it.

or

Making a static class and manually code in all the values.

But I dont like either of them. Doing it manually is too much for for lazy me, and having a data object just seems... inconvinient. Like I will always have this Object in my Hirarchy, begging to be replaced by something more intuitive.

So what I need help with:

Can I make a static class, whose Variables I can edit like in the picture above, without having this data Game Object ruining the perfect View of the mess I call a game?

Maybe something like a custom menu, where I can put all my data? Like the input menu, just for sprites and other variables? I just want to have it organized and easy to edit. Anyone know how or if I can archive this?

question.png (15.7 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
0
Best Answer

Answer by CodesCove · Jan 23, 2021 at 07:06 AM

This might help solving your issue (an probably many other issues :) :

Attach the list to a ScriptableObject not to a Monobehavior. From ScriptableObject (derived) class you can instantiate it as asset in edit mode and you can reference a ScriptableObject (asset) from any Scene component and make use of its data and classes. It also persists across scenes (since it's asset and not scene component). Takes a while to get familiar with but it's really worth it.

Check out these links:

https://docs.unity3d.com/Manual/class-ScriptableObject.html

https://learn.unity.com/tutorial/introduction-to-scriptable-objects

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 Snailtan · Jan 23, 2021 at 09:27 AM 0
Share

This is wonderful, exactly what I wanted! Thank you, you wonderful person!

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

167 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 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 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 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 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 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 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 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 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 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 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 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

Change the target of inspector from script 0 Answers

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

OnInspectorGUI changes reset when played in editor or building 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