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 goten000023 · Jun 05, 2015 at 07:15 PM · c#fpscustomizationbegginer

how to save a prefab of a object during play mode

so here it is i have two scenes.. one is the playing scene were the game is played. and the second scene is were the player can customized guns by instantiating things onto the gun

so the question becomes how to save a prefab of the gun and save it. is this possible to do?

Comment
Add comment · Show 2
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 Creationist · Jun 05, 2015 at 07:21 PM 0
Share

Can you be more detailed? what do you mean by instantiating things onto the gun? are you picking up stuff in the level and using these stuff you can customize your weapon?

avatar image goten000023 · Jun 05, 2015 at 07:47 PM 0
Share

I have a Gun GameObject That I Instantiate a object and then $$anonymous$$ake it a Child of the Gun Object. so what i need to do is to save it that somehow so i can be able to access it whenever i need

2 Replies

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

Answer by Cherno · Jun 05, 2015 at 08:14 PM

Creating prefabs during runtime is only possible if running the game from within the Unity Editor. If you need to create prefabs during runtime of an actual build, you have to create a workaround. For example, you could always use the same prefab which has just the most basic components (MeshRenderer, MeshFilter) and save the information that fills these components; Upon instatiation the prefab, you then use this information to assign the right mesh, materials, children and so on.

Comment
Add comment · Show 4 · 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 goten000023 · Jun 06, 2015 at 04:02 AM 0
Share

ok thanks alot. is there any tutorials on this?

avatar image Cherno · Jun 06, 2015 at 11:16 AM 0
Share

It depends on what you are trying to do, ther can be nore single tutorial that caters to every game's needs. Just think about what you are trying to do, what kind of data needs to be saved and loaded, and go from there.

Here is a short tutorial on saving & loading data which you can use as a base. The "testString" variable in the "Game" class could be the name of a mesh to use, for example, which you would then load via Resources.Load, using the string as the mesh name.

link

avatar image digzou · Jun 06, 2015 at 12:24 PM 0
Share

If there is too much information to save you could try looking into serialization.

http://gamedevelopment.tutsplus.com/tutorials/how-to-save-and-load-your-players-progress-in-unity--cms-20934

avatar image goten000023 · Jun 06, 2015 at 08:10 PM 0
Share

thank you so much for the detailed answer

avatar image
0
Wiki

Answer by starikcetin · Jun 06, 2015 at 12:26 PM

I think the thing you are trying to do is, storing a gameobject and using it later. You don't need to use prefabs for this.

You can just declare a public static gameobject and store your gameobject on it, then whenever you need it Instantiate it from your public static variable.

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

23 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Making an FPS arcade game. 0 Answers

Having trouble increasing the spawning speed of explosions 0 Answers

HOw to make a custom mesh collider 1 Answer


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