public void MakeKids() { for (int i = 0; i < this.transform.childCount; i++) { GameObject child = this.transform.GetChild(i).gameObject; this.enabled = false; AutoFaderController afd = child.AddComponent <AutoFaderController>(); AutoFaderExecution afe = child.AddComponent <AutoFaderExecution>(); afd.Execution = afe; afd.Parent = this; afd.Parent = this; afd.Parent = this; afe.Controller = afd; afd.MakeKids(); afe.Initialize(); afd.enabled = false; afe.enabled = false; } }
// Use this for initialization void Awake() { Instance = this; foreach (Image image in GetComponentsInChildren <Image>()) { image.color -= new Color(0, 0, 0, 1); } foreach (Text text in GetComponentsInChildren <Text>()) { text.color -= new Color(0, 0, 0, 1); } foreach (AudioSource ac in GetComponentsInChildren <AudioSource>()) { ac.volume = 0; } FirstController = this.gameObject.AddComponent <AutoFaderController>(); AutoFaderExecution afe = this.gameObject.AddComponent <AutoFaderExecution>(); FirstController.Execution = afe; afe.Controller = FirstController; FirstController.MakeKids(); FirstController.enabled = false; }