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
0
Question by ryba · Feb 05, 2018 at 10:59 PM · scriptableobjectdatascriptable objectdatastructuredatatype

Are ScriptableObjects good for non-visualised models?

Hi, I want to create a game using only GUI (panels, texts, buttons only), but there will be some models like heroes, monsters, items etc. I have hard time to decide how to code them, thinking about SO or plain class objects. GameObjects with MB seems to be way too overwhelming. I know that SO would make serialization way more easy with it references management, so I did some research about it and found their main use case is holding config-like data (like monster types, item types etc) - but not for instances of them (because thats the job for GO in regular unity3d games) - now I am a bit confused. In my case would it make sense to instantiate new SO each time i want to create new hero, new monster, new item etc, or should I rather use plain object for them?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Bunny83 · Feb 06, 2018 at 01:04 PM

That's completely up to you. Usually if an object (object as abstract concept) has any user interactions or visualization you would need a gameobject. However for pure business logic objects using ScriptableObjects is fine. Also if you use an MVC (model view controller) pattern you can represent your (abstract) model as ScriptableObject while the view and the controller can be gameobjects.


If the general question is: "Can ScriptableObjects be used to represent runtime data" then the answer is Yes.


If the question is if you should do it, that's a question we can't answer. It depends on many factors. What exact properties / values does your (abstract) runtime model contain? GameObjects have a position, rotation and scale for free. Do you need to store / save / serialize your data? If so for what purpose?


For large scale simulations it's common to decouple the visual representation from the logical representation of an object. This adds some overhead since you have to manually link the visual representation to the logic model. However the advantage is that you can easily exchange the visual representation while keeping the logic representation the same. The simulation works soley on the logic model. For example for a large city simulation you may simulate pedestrians and cars. However depending on the zoom level you may represent certain objects just with a simple "dot" or with an actual 3d model.


The great thing about seperating the business logic from the visual representation is that the actual simulation can run standalone. This makes it easier to use multithreading. However the down side is that you have more overhead for communicating external events based on Unity events to your internal model and to actually visualize your model. If you use gameobjects you have everything in one object. That means you can directly react to Unity events and you can directly visualize the object. Though this coupling usually prevents you from using multithreading. It also might complicate serializing / saving the state of your model which is only a part of your object.

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
avatar image
0

Answer by Hurri04 · Feb 05, 2018 at 11:52 PM

you could create something like a "Settings" ScriptableObject and instantiate an instance of it in your project files (e.g. a Resources folder). inside the SO class you can then hold a List etc. if the Enemy class then is a MonoBehaviour that is attached to a GameObject in a scene, serialization should still work.

 

on load you could then iterate through the List and compare the states, delete killed enemies / spawn new instances of enemies if needed and set their HP etc. accordingly.

Comment
Add comment · Show 2 · 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 ryba · Feb 06, 2018 at 09:35 AM 0
Share

I told that instances are not going to be game object because they are not going to be rendered.

avatar image Hurri04 ryba · Feb 06, 2018 at 10:17 AM 0
Share

GOs dont have to be rendered. if they only have a transform and a custom $$anonymous$$B (e.g. Enemy) you'll see nothing.

ofc you can also not use a $$anonymous$$B but then you need to watch out for some serialization pitfalls.

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

78 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

Related Questions

What data format should I store data in? 0 Answers

Giving a ScriptableObject asset reference to all instances of a MonoBehavior? 0 Answers

Instancing ScriptableObject not saved in assets results in warning message 0 Answers

Why do I need to serialize a struct inside a ScriptableObject to save its data? 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