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
4
Question by vexe · Feb 22, 2014 at 02:38 PM · scriptableobjectmemorymonobehaviourunityengine.object

Are MonoBehaviours heavier than ScriptableObjects? what's the difference in memory footprint between them?

When it comes to data storage, first thing that comes to mind is regular C# classes - most the times these work. But if we want this data to be inspected and fully support inspector stuff (multiedit, undo/redo support) then regular classes won't cut it - (For undo for example, Undo.RecordObject takes a UE.Object, and getting SerializedProperties to cope well with your System.Objects is pure pain in the butt....) - so we turn our attention to the other 2 usable classes: MonoBehaviour and ScriptableObject.

Some people use SOs, some use MBs. I tend to use MBs all the time cause SOs don't live in prefabs, and to go around that I'd have to manually create an asset and save it, then update it when I change it, and if I want to add to it I have to AddObjectToAsset (or something)... etc etc. As opposed to just creating an object, attaching it the MB, and just dragging-dropping it to the project folder making it a prefab, and... done.

My question is: Are MBs heavier (in terms of memory) than SOs? Well logically it should be heavier cause SO directly inherits UE.Object, and MB inherits Behaviour, which in turn inherits Component, which inherits UE.Object - so there should be a difference in memory footprint. But how much? how big is that difference? is it one of those differences where you could just ignore it relying on the fact that modern machines these days could handle a lot?

Note: I care mostly about PC builds, not mobile.

Thanks!

Comment
Add comment · Show 3
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 immersiveGamer · Feb 23, 2014 at 08:54 AM 0
Share

I don't think there is any harm in using behaviors to do data storage. I did it effectively before fully understanding scriptable objects. But in the end you are going to run into the same problems of data shearing with inherited classes and references not being serialized. I guess it would be possible to have objects for each one just like how you would create ones for scriptable objects but now you are just adding even more overhead. If it is simple go for it. If not I would invest in a few editor scripts to handle the scriptable objects.

avatar image vexe · Feb 23, 2014 at 09:04 AM 0
Share

I guess it would be possible to have objects for each one just like how you would create ones for scriptable objects

What you meant with 'for each one'?

avatar image immersiveGamer · Feb 23, 2014 at 01:16 PM 0
Share

Just like with scriptable objects if you want to do a list of the class 'Animals' you would need to make the class Animal inherit from scriptable object and then 'Dog' and 'Cat' from that. You could do that but by having Animal inheriting from $$anonymous$$onobehaviour ins$$anonymous$$d. Then you make an empty game object or prefab for each and construct your data structure by copy pasting and dragging or using an editor script. Not recommended at all, but do able.

0 Replies

· Add your reply
  • Sort: 

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

20 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

Related Questions

[Custom Editor] MonoBehaviour vs Scriptable Object 0 Answers

ScriptableObject and Monobehaviour 1 Answer

MonoBehavior, ScriptableObject and Object memory usage & performance 0 Answers

Memory usage of Sprites in a referenced Scriptable Object 0 Answers

Are there any reasons why I should use ScriptableObject instead of MonoBehaviour (or vice-versa)? 3 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