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
1
Question by Math04 · Feb 26, 2015 at 08:14 PM · gameobjectdatabasestore

store a gameobject ?

Hi everyone !

I started developping on unity just a few weeks ago so there's probably a way to do it but I can't figure it out 'till now.

My probleme is that I want to store a gameObject from the hierarchy into a MySql database and eventualy load it back later. It's ok for the connection to the database the probleme is how do I store a gameobject in it.

Thank you for answering.

PS : I use C#

Comment
Add comment · Show 5
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 spiceboy9994 · Feb 26, 2015 at 08:22 PM 0
Share

What exactly do you need to store within the database?... Is it some information in particular? why do you want to store the entire gameobject?

avatar image Math04 · Feb 27, 2015 at 12:33 AM 0
Share

I want to store a 3d object, like a cube, sphere or an hammer etc...

avatar image Math04 · Feb 27, 2015 at 01:43 AM 0
Share

Thanks for all your answers, if I don't misunderstand a serializer allows me to save/load a class in a .xml file. But what I'm looking for is to store a gameobject in a database, maybe it's more accurate to say I want to store a 3D object in a database.

I want to store/load object file (like .obj, .blend, ...). It would be like the Resources.Load but ins$$anonymous$$d of the resources folder I need to load form my database and store other object in it.

The point is that I want a player of my game to be able to load/store objects from/into a database. Later players would be able to share their database with other players.

avatar image meat5000 ♦ · Feb 27, 2015 at 01:52 AM 0
Share

Better to store IDs of some kind and have your app deter$$anonymous$$e what it is. After all, each copy of the game should contain all the information it needs to recreate this object with given information so it makes sense to keep the dataflow down.

avatar image spiceboy9994 · Feb 27, 2015 at 03:21 PM 0
Share

Serialized to xml can be then stored to the database. You need a blob field or a nvarchar field and then store the xml string in there. When retrieve the data, you can deserialize the string into a class instance again.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by maccabbe · Feb 26, 2015 at 08:29 PM

It seems that you are looking for a serializer. A good, free one that is already programmed is the Unity Serializer (http://whydoidoit.com/unityserializer/).

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 spiceboy9994 · Feb 26, 2015 at 08:43 PM

Try this tutorial:

http://wiki.unity3d.com/index.php?title=Saving_and_Loading_Data:_XmlSerializer

The thing is that is going to save particular components of your game object. You can decide to serialize any component attached to your game objects. Just keep in mind that the serialization cannot occur on any class that inherit from Monobehavior, so be wise on how to define your components.

Here's a workaround to serialize a MonoBehavior class:

http://answers.unity3d.com/questions/23734/need-to-serialize-a-monobehaviour-class.html

Regards

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Ai should delete a build turret 1 Answer

Store level data on server using database 0 Answers

Help on making a Database. 0 Answers

Saving/storing in a clash of clans type game 0 Answers

How to implement a store into mobile game 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