• 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 Alturis2 · Nov 22, 2016 at 10:51 PM · prefabprefabsprefab connection

Suggestions for Prefabs which refer to other Prefabs

I understand that Unity3D does not support nested prefabs. While it confuses me as to why such support would not inherently be supported, I am willing to let that go and instead focus on how to achieve a similar result.

Basically what I want to do is have a Prefab A asset which has children instances of other Prefab B assets and when you drag out a Prefab A into your scene it would have all the child instances match the latest version of Prefab B. When Prefab B is updated, it would automatically update all the Prefab B children within Prefab A.

I understand that the moment you create a prefab of Prefab A all of its children are now just included as part of Prefab A and lose their link to Prefab B. But what I am looking for are suggestions on where there may be a clever way to work around this.

I don't really need the Prefab B instances to exist at all as part of the Prefab A. I just need Prefab A to hold references to them. But in order to work with Prefab A they DO need to exist while editing the scene with Prefab A in it.

One thought would be to have some way to manage the limetime of the instances of Prefab B such that they only exist while in the editor editing the scene. But when you save the scene, or save the Prefab A, the instances of Prefab B are dropped with only the references to the Prefab B asset maintained.

I guess what I am looking for is advice from those that may have a longer history of experience with this engine to suggest the best way to handle accomplishing that. I know that during OnBeforeSerialize() and OnAfterDeserialize() utilizing Unity API calls is a no no so I am wondering if such an approach is possible.

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 Sergio7888 · Nov 22, 2016 at 11:14 PM 0
Share

You can create a a code with one public field for the prefab, on the awake of the code instantiate the prefab, set the actual gameObject as the instance parent and destroy the code.

avatar image Alturis2 Sergio7888 · Nov 23, 2016 at 12:53 AM 0
Share

Yes I have a similar system already. But my problem is that I cannot make a Prefab of A without losing its link to B.

And actually that is another issue. Whenever you destroy anything within a prefab that was part of the prefab it loses its link to the original prefab as well.

Both of which is why I was thinking what I need to do is destroy the child prefabs AS the prefab is being created or saved and only load them again when it is loaded into the game or the scene.

This is the specific thing that I am looking for advice on how best to do.

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

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

Related Questions

Unity Programmatically Link Prefab 2 Answers

Prefab clone not updating 0 Answers

Prefabs won't change? 1 Answer

PrefabUtility.ReplacePrefab overrides changes 0 Answers

Game Object is Instantiating on same position 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