Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
This question was closed Dec 11, 2015 at 12:04 PM by Xamur for the following reason:

Andere

avatar image
0
Question by Xamur · Nov 09, 2015 at 11:14 AM · scripting problemprefabsaveparentchild

How to save as prefab when a button is pressed

Hello, I found this Thread but I did not found a good answer. I would like to create a button and if this button is pressed it should save the 2D created Character (<- 'Character' is an Empty GameObject with child Objects attached on it, like 'Arms', 'Legs', etc. and those have a spriteRenderer on them to select the different sprites) with all of its child objects as a prefab.

I have something like this:

 public void SaveCharacterAsPrefab() 
     {
         Transform.Instantiate Character
         int Character
         string prefabPath = "SavedCharacters";
         PrefabUtility.CreatePrefab("Assets/Resources/" + prefabPath + "/" + Character.name + ".prefab", Character, ReplacePrefabOptions.ReplaceNameBased);
     }


But (of course) it doesn't work because I don't know exactly how to 'tell the script' that it should save the Character with all of its child objects and (for example) name/save it as 'Character 1'. I don't know how I can solve it... Thanks for anyone who wants to help!

Comment
Add comment
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 Reply

  • Sort: 
avatar image
0

Answer by OctoMan · Nov 09, 2015 at 11:50 AM

Read this, it might help you out. http://prof.johnpile.com/2014/07/27/generateprefab/

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 Xamur · Nov 09, 2015 at 09:49 PM 0
Share

Well, it's good but I cannot do a working script for my project on my own. I just don't know how to change/add things to some of those scripts so it's working for me, too... :(

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How do I make character pick up object to front of him? 1 Answer

Set parent of an object when they collide? 2 Answers

How do I spawn an array of prefab clones as children of an object? 1 Answer

Why does importing a mesh create a parent. 0 Answers

how add child to multi gameobject 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