0
\$\begingroup\$

The Scene Fader prefab is dragged to the OnGameLoading script :

Scene Fader

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

Scene Fader 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.

\$\endgroup\$
1
  • \$\begingroup\$ Presumably you tried GetComponentInChildren? \$\endgroup\$
    – DMGregory
    Sep 17 at 1:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.