Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 Desync404 · Jul 23, 2015 at 09:03 AM · unity5

Loading a ScriptableObject from an Asset at Runtime (after downloading + caching)

I've made a plugin whereby the user can directly edit the quests (and other things like items etc.) that are to be used in the game. It uses Unity's ScriptableObjects and Assets.

Here is a diagram showing how the system works.

To summarise the diagram:

  • QuestDatabaseEditor creates new Quest object and stores it inside QuestDatabase (which is a Scriptable Object).

  • QuestDatabase is stored inside questDB.asset.

  • questDB.asset is bundled inside questDB.unity3d, an Asset Bundle.

  • On RUNTIME, questDB.unity3d is retrieved and questDB.asset is loaded.

THE PROBLEM is that I can't figure out how to get the ScriptableObject (QuestDatabase) out of questDB.asset on run-time! The game successfully loads the asset but I don't know to specifically get the ScriptableObject out so that it can be used.

If this isn't possible I will be switching to XML, however I'm unsure on how to serialize dictionaries in XML. I'm also open to suggestions on more suitable methods of serialisation. Thanks in advance.

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

Answer by Bunny83 · Jul 23, 2015 at 09:45 AM

Well, i haven't really used AssetBundles but AssetBundle.LoadAsset should just do what you want.

So in your case it should look something like:

 // C#
 var questDB = yourAssetBundle.Load<YourScriptableObjectType>("questDB");

As you can read on the linked page it's no longer possible to load individual components derectly from prefabs inside the bundle, but ScriptableObjects should still work as they are seperate assets.

If that doesn't work or if you don't know the name of the asset inside the bundle you could try using AssetBundle.LoadAllAssets instead and grab the one you want from the returned array.

edit
If the data should be editable after a build, it's usually easier to use a common format as you mentioned. XML and JSON are the common ones but there are others as well. Unity's serialization system has it's limits. Since it now supports the serialization callbacks it has become much more useable, but you're still bound to the Unity editor to save / serialize / create assets.

One small advantage of assetbundles is that they can't be modified that easy by cheaters. Since XML and JSON are human readable formats it's much easier. However since you want your users to edit those files i would recommend using XML or JSON. That also allows to create an editor for your database without requiring Unity or even integrate an editor into your game.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Merge conflicts in main level scene 2 Answers

I want to create app in mobile and PC. what should I use for the database? 1 Answer

Can't change properties of one object by using another object's information 0 Answers

Trees that I painted on terrain are really dark and also missing parts in it's hirearchy... 0 Answers

Sorting Layer not working 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