Hello, I’m trying to use a script to add a script component to all of the children of the object. This script is not directly placed on the object so I’m not sure if I need to use GameObject.Find() in some cases. Below I’ve posted some code I’ve put together that doesn’t work. It just keeps giving errors about the add component function. Any help would be appreciated
void Start () {
Transform[] allChildren = GetComponentsInChildren<malenude>();
femaleNude = GameObject.Find("femalenude");
femalenudeScript = femaleNude.GetComponent<FemaleNude>();
femalenudeScript.ChangeEnabled(false);
foreach (Transform child in allChildren) {
child.AddComponent(MaleNude);
maleNude = GameObject.Find(Transform);
malenudeScript = maleNude.GetComponent<MaleNude>();
malenudeScript.ChangeEnabled(false);
}
}