References to Prefab children#

You cannot directly reference children of a prefab externally.
Instead, create a script on the root of the prefab that contains the references.


Follow these steps to reference a child on a prefab instance:#

  1. Understand how to reference and instantiate prefabs from scenes and do this for a script on the root of your prefab.
  2. Reference the target child component from the root component.
  3. Now, when the prefab is instanced you can use your root component to access the child.

You can understand the root component as a manager, handling any interactions with its children. Create methods on this component to manage those objects, compartmentalising interactions instead of modifying things directly.

#font: "Roboto", sans-serif #fontSize: 11 #fill: #282828; #282828 #stroke: #D0D0D0 #arrowSize: .8 #fillArrows: true #lineWidth: 2 #gutter: 1 #edges: hard [In-Scene Component]->[Prefab| [<hidden>]->[Children] ] In-Scene Component Prefab Children

If you are still unsure what objects can reference each other, refer to the valid references diagram.