[HELP] Unable to Activate DontDestroyOnLoad Objects Children

Thank you for taking time to review this issue.

I have an Empty Game Object with this script attached:

using UnityEngine;

public class FishManager : MonoBehaviour
{
    static FishManager instance = null;

    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            GameObject.DontDestroyOnLoad(gameObject);
        }
    }
}

Then I have this script attached to the children of that object:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Unlockables : MonoBehaviour
{
	public int unlockedAtLevel = 5;
	private LevelManager levelManager;
	
	void Start ()
	{
		levelManager = LevelManager.instance;
	}
	
	void Update ()
	{
		gameObject.SetActive(levelManager.currentLevel >= unlockedAtLevel);
	}
}

LevelManager is also another script attached to an empty object, which is named LevelManager, that is DontDestroyOnLoad as well.

When I do this with other objects in the scene that are NOT DontDestroyOnLoad, everything works great!

However, when I have a DontDestroyOnLoad Parent Object with children that I want to activate it does not work.

Let’s say a FishManager Object that has a DontDestroyOnLoad script attached with prefabs of fish as children objects and the Unlockables Script attached to the fish prefabs… the fish prefab does not activate when the currentLevel is achieved.

In the Unity Editor, the script is Active and the child-object is deactivated, as it should be. But the child-object never activates when the bool = true.

I got it working with the following code through hours of trial and error. The following example shows how to activate different children from a Parent Object that is DontDestroyOnLoad:

using UnityEngine;

public class Unlockables : MonoBehaviour
{
	public int unlockAtLevel = 3;
	private LevelManager levelManager;
    private GameObject Fish;
    private Transform goldFish;
    private Transform blackAndWhiteFish;
	void Start ()
	{
		levelManager = LevelManager.instance;
        //Finds and assigns the object named "Fish".
        Fish = GameObject.Find("Fish").gameObject;
        
    }
	

    void FixedUpdate()
    {
        //If Fish was found, search for the child.
        if (Fish != null)
        {
            //Find the child named "goldfish" of the gameobject "Fish" (goldfish is a child of "Fish").
            goldFish = gameObject.transform.Find("goldfish");
            blackAndWhiteFish = gameObject.transform.Find("Black_White_Fish");
            //If goldFish was found.  GetChild(from top to bottom in Hierarchy count from 0 to your object) then SetActive(once this bool = true)
            if (goldFish != null)
            {
                transform.GetChild(10).gameObject.SetActive(levelManager.currentLevel >= unlockAtLevel);
            }
            if (blackAndWhiteFish != null)
            {
                transform.GetChild(3).gameObject.SetActive(levelManager.currentLevel >= unlockAtLevel);
            }
        }
    }
}

Hope this helps anyone trying to figure it out in the future. I can successfully Activate and Deactivate children of a DontDestroyOnLoad Object, which was a tough cookie to crack. You have to do everything through the Parent Object and attach scripts to the Parent Object.