Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
3
Question by pickledzebra · Jul 06, 2010 at 11:23 PM · prefabruntimesavestate

Creating/Saving prefabs during runtime?

This questions regards events after a scene has started (after asset processing, start() or awake() functions).

Somewhat similar to saving a game state or player prefs, I'm looking for a way got save the state of a gameObject at some arbitrary time, having undergone arbitrary dynamic changes, and store it permanently.

For example, I'd maybe "grab gameObject A at Time=1000 seconds".

I'm asking specifically about prefabs, as I'd potentially like to include these in other scenes later on.

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 alok.kr.029.hotmail · Mar 05, 2014 at 01:03 PM 0
Share

hi I have to crate a prefab at runtime and save it as we are making a application where a player can create object scale change texture draw lines created wall and I have to save it at runtime and load it .this cannot be done by by searlizable as each object has different name in the hirercy than in its actual prefab

what I am planning is to create a prefab at runtime and put all the object inside the prefab and save it when the player calls the load function we just have to load the prefab.

is this possible....

7 Replies

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by qJake · Jul 07, 2010 at 04:44 AM

As far as I know, you can't do this at runtime. In fact, it's really hard to try and save anything at runtime (as that's not how Unity's designed to function).

You can, however, do it when the game isn't running (with an Editor script, that goes in the /Editor/ folder), like this:

Use EditorUtility.CreateEmptyPrefab to create an empty prefab object, and then once you have that reference (as well as the game object that you want to save into it), you can use EditorUtility.ReplacePrefab to "save" the game object inside the prefab you just made. Be sure to name your prefab something unique so it doesn't get overwritten.

Comment
Add comment · Show 2 · 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 pickledzebra · Jul 07, 2010 at 12:29 PM 0
Share

ah, ok. I think this might work for what I'm trying to do. Thanks!

avatar image pickledzebra · Jul 07, 2010 at 12:54 PM 2
Share

Do you happen to know a place to learn about creating Editor scripts and how to implement them?

avatar image
3
Best Answer

Answer by Tetrad · Jul 07, 2010 at 07:02 AM

While not specifically about saving prefabs, this question talks about saving the state of a game object during run time.

http://answers.unity3d.com/questions/4308/is-there-any-solution-commerical-or-otherwise-to-save-properties-of-game-object

Comment
Add comment · Show 2 · 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 pickledzebra · Jul 07, 2010 at 12:29 PM 0
Share

thanks for the pointer.

avatar image pickledzebra · Jul 11, 2010 at 02:51 PM 0
Share

I believe there is a way to do this using ExecuteInEdit$$anonymous$$ode(). However, I can't quite seem to figure out how to merge meshes in Edit $$anonymous$$ode. ???

avatar image
3

Answer by Joe-2 · Jan 28, 2011 at 08:37 PM

You can manually copy the gameobject you are editing at runtime, and paste it in the editor later. It is like creating a carbon copy. If it's easy to insert that cc back into your instance pool, then this should be useful to you. Be aware though that it will contain any runtime changes that you are doing, such as attaching scripts or changing names, etc.

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
1

Answer by Vectrex · Dec 08, 2012 at 05:14 AM

There's an asset store thing called 'PlayMode persist' I think. I use it, it works quite well.

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 drudiverse · Apr 02, 2014 at 10:25 AM

found this script": class CreatePrefabFromSelected its awesome apart from the generated mesh isnt in ther on that version

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
  • 1
  • 2
  • ›

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Saving gameobjects' properties for Dynamically growing prefabs 1 Answer

create prefab at runtime 0 Answers

Saving object like a prefab at runtime 1 Answer

Avoid altering prefab at runtime 1 Answer

Best method to save states in/for a prefab 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