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
2
Question by skail · Oct 24, 2011 at 03:36 PM · javascriptsaveloadgame object

Saving and Loading an Object and it's Children in Javascript

SO I have an editor that allows you to place objects on another object. It attaches them with fixed joints. I need to be able to save the parent object and all it's children so that it can either be reloaded in the editor or loaded into the game later. each of the objects have scripts attached to them also. I have not yet delved into saving and loading files in unity and have had some difficulty in finding good tutorials explaining how to do this. If anyone can help it would be greatly appreciated. also I am operating in Javascript.

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 skail · Oct 29, 2011 at 03:56 PM 0
Share

Ok, I have done a little looking into all this now (thank you for your input), I still honestly am not sure what all your talking about but I did find some things about PlayerPrefs which at least got me to thinking about what all I need to be saving out once I figure the process of actually doing that.

The way I figure it I need to save out at least these key pieces of information and then have a load function that takes in the info and basically rebuilds the stuff based on the data: The Object Type The Object Tag The Object Parent The Object x position The Object y position The Object z position

I figure by somehow using an array or arrays I can grab and organize all this data while exporting it (im going to try and use player prefs as it seems easy enough to me) and then reloading it and using a function to reload the prefabs, place the parts in the proper positions, organize the hierarchy, fixed joint the parts together and assign the proper tags.

I will be trying this later today and will let you know how it goes. Also any advice on doing this would be appreciated.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by DaveA · Oct 24, 2011 at 07:58 PM

I've done that with X3D as the format.

Basically, you pick a format that works for you. X3D's spec allows for scripting, but it does not translate well to Unity, so what I did was use X3D's 'proto' nodes to save and load references to Unity prefab files (which can contain scripts, of course). I save the transforms and hierarchy, then reference to the prefab.

I've also done this using CSV as the file format.

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 Harabeck · Feb 10, 2012 at 08:30 PM 0
Share

How did you save the references to prefab files??

avatar image
0

Answer by jahroy · Oct 24, 2011 at 09:07 PM

The easiest way to read from a file is to use TextAssets. They make everything related to reading a text file EXTREMELY easy.

I'm pretty sure you have to use System.IO to write files (or some library).

Like DaveA said, it sounds like you will also probably need to use XML for what you're after.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Save and load data with Javascript... 0 Answers

How to load saved data from another scene? 2 Answers

Saving lots of objects (Only answer in JavaScript) 1 Answer

Trying to save/load game, codes doesnt do anything. not even an error. 1 Answer

simple checkpoint/save/load system in javascript 4 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