Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Orokon · Dec 04, 2021 at 03:30 PM · scriptableobjectscriptable objectarchitectureeditor scripting

Should I work with scriptable objects like that?

I'm currently working on editor windows (with Odin) and trying to make everything configurable from the editor.
I am trying to build up a structure where all stuff is configurable in the editor.


For example:
A spaceship is built up by Attributes, Equipment, Cargospace (holding commodities) etc.
I have built a scriptable object for the type "spaceship" as "spaceshipData". It represents different kinds of spaceships.
With that I can have a gameobject, drop a spaceshipData SO on it and that decides what "kind" of spaceship it is and what "stuff" it has like attributes etc.


Now comes the more difficult part.
I have for example cargospace. A ship (MonoBehaviour) can have a public Cargospace commodityCargospace = new Cargospace();
The cargospace has a size attribute and a list of commodities it holds.

 public float size = 10.0f;
 public List<Commodity> storedCommodities;

The commodity is a monobehaviour like ship and there are SO's for each type of commodity there is (like AlienArtifacts or Minerals)


To configure the spaceship in editor to have stuff already in the cargospace I would need monobehaviours using the commodity SO.
That would mean I would need a copy of each commodity SO as a prefab with the SO attached so I'm able to set it in the array in the editor.
Thats not what I want because that would be pretty redundant.
How can I achieve the same thing without having a prefab for every commodity SO?


I hope it is understandable what I want, it's kinda difficult to explain.
Don't hesitate to ask for clarification please.

Thanks in advance!

Comment
Add comment · Show 1
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 KittenSnipes · Dec 04, 2021 at 10:17 PM 0
Share

So you can just make it so the commodity class has either an id or name so that way each commodity is different and you don't need a prefab. You would need a method that knew what each id or name meant but it should do the trick.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Orokon · Dec 05, 2021 at 08:06 PM

Current solution

Changed storedCommodities to a Dictionary where CommodityData is the SO and the float determines the quantity stored.

Future problems arise

This will work for now but im sure I will tap into the same issue later.
What if I would like to not only have a float for the quantity. For example there could be degrading commodities that lose weight over time.
Weight is currently stored in the SO because it is not variable.

Comment
Add comment · 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

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

139 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

Related Questions

Unique function for each instance of a scriptable object 2 Answers

Scriptable Objects with editable functions 1 Answer

target of triggers on eventtrigger is null when reload scriptableObject how to fix it? 0 Answers

Why child ScriptableObjects class instance cannot be placed in their parent ScriptableObject field in the inspector? 1 Answer

Make the same serialized class as a ScriptableObject? 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