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
0
Question by Sarthak123 · Nov 04, 2014 at 02:42 PM · prefabsaving

Is There A Way To Save A Whole Prefab?

hi everyone, i am creating a game where user will create some blocks ( lets say like minecraft ), next i want is that, when the user exits the game, all the blocks that he has created so far, combine into a single prefab, named " MYBLOCKS " and save that prefab to a harddisk, and when i load the game, the prefab itself loads(it contatins all the blocks, so all of them will also appear at the positions they were before)

is it possible somehow?

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 Sarthak123 · Nov 05, 2014 at 08:59 AM 0
Share

help please

avatar image robertbu · Nov 05, 2014 at 09:08 AM 1
Share

Cannot be done this way. Prefabs are editor constructs.

avatar image Sarthak123 · Nov 05, 2014 at 09:30 AM 0
Share

anyother method similar to this?

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by frarees · Nov 05, 2014 at 09:20 AM

Prefabs as you know them on editor do not exist at runtime. What you are looking for is called serialization at runtime. There're several solutions out there. You can try UnitySerializer

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 Sarthak123 · Nov 05, 2014 at 09:29 AM 0
Share

cant do serialization, i find it more than just complicated for me

avatar image
0

Answer by Redeemer86 · Nov 05, 2014 at 09:23 AM

I think you just need dynamic parenting during runtime and save the transform values to achieve that effect... If I get what you want ...

Red

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 Sarthak123 · Nov 05, 2014 at 09:30 AM 0
Share

but how would i load each individuals's name and transform values, can u explain a little more clearly..

avatar image
0

Answer by Mathieu_Dossmann · Nov 05, 2014 at 09:36 AM

A "simple" solution is to create a save file containing informations about your objects, whatever they are. The file can be in xml if you want a tree structure, a database or a simple csv file, even a text file if you want. An object contains a position, a rotation, a texture or / a light, and so on, and you'll need to determine what information is need to instantiate them in order to get the same result previously saved.

The way you manage and structure these informations and files is up to you. You could eventually see if on the assets store there is a save file manager that'll match your expectation.

Aside that, i strongly suggest that you look into file management with unity and the script language you are using.

Comment
Add comment · Show 7 · 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 Sarthak123 · Nov 05, 2014 at 09:44 AM 0
Share

ah yes i know about, System.IO.File.WriteAllToText command, and yes it might help me also, but the problem is, if i use that, than i have to create a single file for a single attribute, and that accounts to 4-5 files per object, is there any way to save all the cordinates and rotation to a single file and read all those data from a single file(for a object), by simple use of this command by the way, it would help me very much...!

avatar image Mathieu_Dossmann · Nov 05, 2014 at 10:06 AM 0
Share

Why would you want to save each properties in separate files per object? You can save multiple objects with multiple informations for each in a single file. X$$anonymous$$L for example : X$$anonymous$$L Tree

And so on. In file management (as a whole) it's always a combination of multiple commands to check,locate,write and read informations. Each type of data "file" (xml, sql table, csv, etc) has usually standards about structure and how to retrieve it.

Serialization is nice because you save the whole object and its informations in a file.

avatar image Sarthak123 · Nov 05, 2014 at 11:01 AM 0
Share

any ideas from where i can learn this X$$anonymous$$L serialization?

avatar image Mathieu_Dossmann · Nov 05, 2014 at 11:30 AM 0
Share

About X$$anonymous$$L : eXtended $$anonymous$$arkup Language

About C# and Serialization (X$$anonymous$$L included) : Serialization

avatar image wijesijp · Nov 05, 2014 at 12:33 PM 0
Share

Why not create a delimited string and read and write it to file

eg:- object_type,location,rotation|object_type,location,rotation ...

After reading this string from file split the string first with "|" then with "," You the all the information about your objects

When you write the data to a file simply construct this string and write to file

Show more comments

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

29 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 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 avatar image

Related Questions

How to create prefab from a GameObject variable in class? 0 Answers

What is the best way to load an instance of a gameObject when loading a saved game? 0 Answers

Ingame prefab saving and manipulation 0 Answers

Pressing Apply Breaks Prefab 1 Answer

Dynamically saving and loading player-created prefabs 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