I'm having a trouble of getting the child from an array of GameObject
Here's my script:
[SerializeField]
GameObject[] CameraScriptsTV;
protected override void SetPosition()
{
CameraScriptsTV = this.gameObject.transform.GetChild(0).gameObject; //here is the error
foreach (GameObject TV_CameraScript in CameraScriptsTV)
{
TV_CameraScript.GetComponent<Bloom>().enabled = false;
}
}
I'm getting the child using what has been written on Transform.GetChild.html
What I am trying to do is like this for example:
In this script I get the child from the Camera in my hierarchy : Image Reference
CameraScriptsAir_1 = this.transform.GetChild(0).GetChild(1).GetChild(0).GetChild(2).GetChild(0).gameObject;
CameraScriptsAir_1.GetComponent<DepthOfFieldDeprecated>().enabled = false;
CameraScriptsAir_1.GetComponent<Bloom>().enabled = false;
So what i am getting here is the AIR_1(Clone) then get the script Bloom.cs and DepthOfFieldDeprecated.cs.
I hope its clear.
GetChild(0)returns a singleTransform. Getting that single Transfrom'sGameObjectcan never, and will never, result in an array of anything.GameObject to GameObject[]something like that