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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by traemyn · Dec 17, 2012 at 04:28 PM · gameobjectscriptableobject

Why would you use a scriptable object versus an empty gameobject?

It seems like these two objects fulfill a similar role in that you can use them for scripts/data that don't require user input or anything physical interaction with the object itself.

Does the difference boil down to that you 'save' resources by choosing scriptable object if your scripts/data doesn't need all of the properties of a GameObject?

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 Karsnen_2 · Dec 17, 2012 at 04:38 PM 0
Share

I think the economical usage of the resources on a scriptable object vs an empty game object is highly negligible. If you use a GameObject with a script on top of it, then your hierarchy might look a bit organized.

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by maleone0487 · Jan 08, 2013 at 03:36 AM

I'm not sure if this is a good answer to your question, but I came across this issue in a recent project. I was attempting to create large tile grids (at least 128x128), and when the those tiles were components attached to game objects I was getting out of memory and heap exceptions when creating grids even as large as 150 x 150. I have since switched to having my tile class inherit from Scriptable object, and can comfortably get grid sizes of 256 x 256, even as high as 1536 x 1536 before I get any crashes or out of memory/heap exceptions. To put this in perspective, I was seeing crashes when creating 16,384 game objects (128 x 128), but I didn't see the same crashes until attempting to create 2,359,296 Scriptable Objects (1536x1536).

To me it seems that the best reason to use Scriptable Object vs an empty game object is when you need to create large quantities of that object, or creating a whole new game object would be too cumbersome. In my case, I've had to write a few extra tools to allow the tile map to be edited by hand, so if I were able to use a game object my whole system would be much simpler. It is also important to point out that ScriptableObjects get serialized by unity, and can be saved as asset files, which allows for easy loading by other 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 donderper · May 30, 2014 at 12:28 PM 0
Share

Roughly speaking how did you implement this? I have a tile class which stores information about its neighbouring tiles and whether it is passable or not. Like yourself this is attached to a game object which also has a sprite renderer. There is a grid manager class which instantiates the tile game object and stores the corresponding tile class in a dictionary.

From what I understand of your answer, you switched your tile class (which might not be equivalent to $$anonymous$$e) to inherit from ScriptableObject. I don't quite understand how this gets around having to instantiate a game object.

There are a few different tutorials for scriptable object but they mostly involve tools to edit stuff at runtime which is irrelevant as I'm working with procedural generation. I just want to instantiate a tile object which can store information and be visually represented and your implementation sounds pretty close to that.

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

12 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

Related Questions

Instantiate with random scriptableObject 2 Answers

Is each call to persitante script creating a new script 1 Answer

How to reference a scene gameobject from a custom project asset? 2 Answers

Need some advice for my inventory system 0 Answers

ScriptableObject performance 0 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