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
3
Question by Macro · Aug 01, 2014 at 09:45 AM · prefabprefab connection

What does it mean to link prefabs?

I have read over some of the best practices regarding prefabs but it is all very wooly in the area around managing multiple prefabs via composition.

So for example lets say you have a Player prefab, which contains a child model and a child behaviour tree. Now if you want the behaviour tree to be its own prefab then the moment you attach it to the player prefab it loses its connection.

So it was mentioned a few times to link prefabs, but what does this actually mean from an implementation point of view?

http://devmag.org.za/2012/07/12/50-tips-for-working-with-unity-best-practices/

That is the article that specifically says it.

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

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

Answer by rutter · Aug 01, 2014 at 09:59 AM

As best I can see, when they say "link" they mean a reference variable (sometimes called a "pointer").

Something like this, which you might set in the inspector:

 //JS
 var jetpackAudio : AudioSource;

 //C#
 public Transform myTarget;

18 . Link prefabs to prefabs; do not link instances to instances.

The two example references I mentioned above serve different purposes:

  • "jetpackAudio" is probably an internal link to another component within the prefab.

  • "myTarget" is probably an external link to some other object in the scene.

In the one case, the jetpack audio reference will (probably) be the same every time you drop the prefab into a scene. The audio is part of the prefab. So that reference should probably be built into the prefab asset itself. You can do that by editing the prefab in the project panel, or by editing in a scene and selecting the "apply" button.

In the other case, the "target" is probably not part of the prefab. It doesn't make sense to make it part of the prefab, because it'll have a different target every time you drop it into a scene. That reference should probably be left blank, then set per-instance.

17 . Use separate prefabs for specialisation; do not specialise instances.

In this case, I think they're just saying that it doesn't make sense to have a single prefab for both "BlueEnemy" and "RedEnemy". If they're really different enemy types, they might as well get their own prefabs.

If need be, you could even create a third prefab that's able to spawn either enemy type on demand. Maaaybe that's what they mean by this "link" thing?

Getting your components to reference each other is a huge part of scripting. This guide is just giving some general tips for going about that, I think.

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 Macro · Aug 01, 2014 at 10:04 AM 1
Share

AH so the key part is they advocate having a component to basically handle the linking of dependent prefabs, I assumed there was some hidden functionality, but that seems correct.

I completely agree that you want to isolate prefabs as small as you can so they can be more re-usable!

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

Change Prefab Source/Change material on ALL prefabs in the scene 0 Answers

Patterns for reusing, inheriting from, or extending GameObjects or Prefabs. 0 Answers

Prefabs won't change? 1 Answer

PrefabUtility.ReplacePrefab overrides changes 0 Answers

How to make prefab reference in another prefab 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