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 question was closed May 20, 2013 at 07:11 AM by FWCorey for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by FWCorey · Apr 15, 2013 at 06:54 PM · c#prefabserialization

How do I Serialize an imported asset?

Since Unity doesn't use the ISerializeable interface to serialize and deserialize classes, (At least it doesn't seem to for custom classes), how can I serialize a runtime Unity class so I can store it and load it later from a binary stream? In particular, fonts, atlases and GameObject prefabs.

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 whydoidoit · Apr 15, 2013 at 07:46 PM 0
Share

In the editor to create assets or at runtime?

avatar image FWCorey · Apr 15, 2013 at 07:55 PM 0
Share

I need to deserialize at runtime but I'm fine with serializing in the editor. I wish they had GetObjectData() :P

avatar image whydoidoit · Apr 15, 2013 at 08:35 PM 0
Share

Well there's my Unity Serializer (also on the Asset Store) that will save many things - but not custom fonts (it would save the fonts you'd applied to something, but not the actual font textures). It can rebuild an object from basic components like a prefab etc.

What I sometimes do is use that to create a byte[] which I embed in a normal object and load it from there - or you could just make a file etc.

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by MartinCA · Apr 15, 2013 at 09:30 PM

Just out of curiosity - what is the use case you intend for that feature?

Unity already serializes interally all imported assets and bundles them by scene reference. If you would like to have assets available at runtime without any scene dependency, you can use Unity's Resource pipeline.

In addition to bundling assets by scene, unity also serializes all supported* asset types in your Resources folder, which you can then load at runtime using Resources.Load(). And, well, anything which is not supported is probably not a MonoBehaviour, so you can implement ISerializeable yourself :P

Another existing solution ( which I have no experience with, I must admit ), is asset bundles. Might be worth giving that a reading.

Either way, it sounds like you are working to implement an already existing feature, I highly suggest you take a look at the Resource class documentation and see if it fits your need before reinventing any wheels :)

Comment
Add comment · Show 3 · 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 FWCorey · Apr 15, 2013 at 09:59 PM 0
Share

I want to embed assets in a dll as compressed binary files. In particular a list of prefabs and a GUISkin complete with fonts and have the whole thing compatible with Unity Free.

avatar image MartinCA · Apr 15, 2013 at 10:02 PM 1
Share

Are you trying to create a plugin, or is there a reason to obfuscate these assets? Because otherwise Resources does exactly that, only ins$$anonymous$$d of a dll, it serializes everything to proprietary format ( Unity's .sharedassets )

avatar image FWCorey · Apr 15, 2013 at 10:06 PM 0
Share

I though prefabs had metadata that was specific to the project that holds them? This is not exactly a plugin it's a general utility library that has to be portable across 7 projects.

Follow this Question

Answers Answers and Comments

14 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

Related Questions

Distribute terrain in zones 3 Answers

Multiple Cars not working 1 Answer

Instantiate already connected players. 0 Answers

Making change to an instance of a prefab doesn't work... 1 Answer

How to make TCG Deck (Instatiate based on Prefab) 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