# How to get a reference of a script from prefab child?

The Scene Fader prefab is dragged to the OnGameLoading script :

The scene fader prefab structure is with two children and the script I need to get a reference to is on the second child :

And the script I try to reference to the script on the second child : At the top :

public SceneFader sceneFader;


And in the Start()

void Start()
{
StartCoroutine(sceneFaderPrefab.Fade(sceneFaderPrefab.FadeDirection.Out));
}


Both sceneFaderPrefab.Fade and sceneFaderPrefab.FadeDirection the Fade and FadeDirection are not exist because I need to get reference to the script on the second child of the sceneFaderPrefab.

Is there any easy way to get a reference to the script on the second child of the prefab ?

I thought adding a private SceneFader sceneFaderScript variable and than somehow to find the script on the second child of the sceneFaderPrefab but not sure if this is the right way and how to do it.

• Presumably you tried GetComponentInChildren? Sep 17 at 1:00