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 Alanimator · Dec 19, 2013 at 11:26 PM · c#files

How do I Save instantiated Bundle to scene ?

how do I save my instantiated objects to my scene . for example i have instantiated "bubblemoon" in my scene how do i go about saving that object to the scene so that it remains in the scene at next run-time.

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 skylem · Jul 21, 2014 at 03:26 AM 0
Share

Thnx, being able to instantiate in edit mode is a quick fix for exactly what i wanted to do, by only firing once with a count, i can make it so any object my player builds is saved to the scene on a GUI button press, thnx again.

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by iwaldrop · Dec 20, 2013 at 06:12 AM

If you're talking about doing it magically, it doesn't work that way. What you'd have to do is implement saving functionality. That means that any dynamic elements of the scene that aren't emergent or can not be inferred by other object's states needs to be saved to disk for reloading when the player reenters a given scene. It's quite a task. You must ask yourself several questions before proceeding.

  1. Will there be multiple players, or save-games? Typically, this is true, like in Oblivion or Resident Evil.

  2. Is the player allowed to travel from scene to scene freely, or is it a linear experience? If linear, the task is greatly simplified, because you can discard stale information (like previous scenes) and only save the current one and player inventory and the like. Otherwise if you can travel all over, like in Fallout, you need to save some of the state of the entire world.

  3. Is it multiplayer? If so, each copy of the save game needs to maintain everything for every player for the reasons of preventing cheating, unless you use some checksums to detect altered save game files.

  4. Is the world procedurally generated, like Minecraft? If so, you'll have to save the entire damn world.

Good times, for sure, but very doable if broken down into small chunks of work.

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 Alanimator · Dec 23, 2013 at 07:14 PM 0
Share

Well basically i am running my entire game in one scene . All that is really need is for the name of my instantiated gameobject to be saved so that whenever the game is next played the name the name will be added to an empty gameobject.

funny i should say that because i know exactly how to do it but i'm considering not having the instantiated gameobject being empty in the first place so saving each name in an array and assigning them to instantiated empty gameobjects is a no no.

I dont think it would be as complex to do in my situation as you make it sound but you are absolutely right if i wasn't just using one scene. the game is single and multiplier but that wont be an issue.

Anyway i'm going to quickly create a function to save and instantiate object with the desired name.

avatar image Alanimator · Dec 23, 2013 at 09:47 PM 0
Share

i have decided to add a .txt file to each exported bundle that is to be imported and saved in my scene so . simply saving the name of each instantiated object is no longer an option.

I guess this will be a bit difficult after all.

avatar image iwaldrop · Dec 24, 2013 at 06:55 AM 0
Share

I didn't mean to make it sound hard or complex; just wanted to convey that developing a solution requires sound analysis of the problem.

It doesn't sound like it should be that difficult in your case if you can serialize a component to disc. That component will simply have an array of custom, serializable, objects that it tracks and then, when loaded, will instantiate n number of GameObjects with the configuration information that's in your custom class. I would stay away from text if I were you, just use a BinaryFomatter. ;)

avatar image
2

Answer by supernat · Dec 20, 2013 at 06:19 AM

Funny, someone else just posted that their objects were staying in the editor after they stopped playing. Anyway, you might find something in the Asset Store to do this for you. Otherwise, you can add a script that copies the properties (transform, etc) of the object each frame and monitor the Application.isPlaying property. When it changes state, create a new object with the same name and copy the properties into it.

You need this script to execute in Edit mode (after you exit Play), so add the ExecuteInEditMode attribute: http://docs.unity3d.com/Documentation/ScriptReference/ExecuteInEditMode.html

You would attach this script to the prefabs right after you instantiate them for optimal results (i.e. don't want to run it on all of the objects in the scene).

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

22 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

File.Move wont work , error. IOException: Win32 IO returned ERROR_ALREADY_EXISTS. Path: 1 Answer

Initialising List array for use in a custom Editor 1 Answer

Will System.IO.File work on Macs 2 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