Could someone help me optimize my code below . I'm not satisfied with this though it gets what i want and execute what i want.
[SerializeField]
GameObject CameraScriptsAir_1,CameraScripstAir_2;
[SerializeField]
GameObject[] CameraScriptsTV;
[SerializeField]
GameObject[] TwoScript;
[SerializeField]
GameObject[] Tests;
[SerializeField]
GameObject FogEffect;
void Update()
{
if (tzPlayInfo.Instance.BLOCK_GAME_FLOW == false)
{
CameraScriptsAir_1 = this.transform.GetChild(0).GetChild(1).GetChild(0).GetChild(2).GetChild(0).gameObject;
CameraScripstAir_2 = this.transform.GetChild(0).GetChild(1).GetChild(1).GetChild(2).gameObject;
CameraScriptsTV[0] = this.transform.GetChild(0).GetChild(1).GetChild(5).GetChild(0).GetChild(0).gameObject;
CameraScriptsTV[1] = this.transform.GetChild(0).GetChild(1).GetChild(6).GetChild(0).GetChild(0).gameObject;
CameraScriptsTV[2] = this.transform.GetChild(0).GetChild(1).GetChild(7).GetChild(0).GetChild(0).gameObject;
TwoScript[0] = this.transform.GetChild(0).GetChild(1).GetChild(8).GetChild(0).GetChild(1).gameObject;
TwoScript[1] = this.transform.GetChild(0).GetChild(1).GetChild(38).GetChild(0).GetChild(0).gameObject;
//29
Tests[0] = this.transform.GetChild(0).GetChild(1).GetChild(9).GetChild(0).GetChild(0).gameObject;
Tests[1] = this.transform.GetChild(0).GetChild(1).GetChild(10).GetChild(0).GetChild(0).gameObject;
Tests[2] = this.transform.GetChild(0).GetChild(1).GetChild(11).GetChild(0).GetChild(0).gameObject;
Tests[3] = this.transform.GetChild(0).GetChild(1).GetChild(12).GetChild(0).GetChild(0).gameObject;
Tests[4] = this.transform.GetChild(0).GetChild(1).GetChild(13).GetChild(0).GetChild(0).gameObject;
Tests[5] = this.transform.GetChild(0).GetChild(1).GetChild(14).GetChild(0).GetChild(0).gameObject;
Tests[6] = this.transform.GetChild(0).GetChild(1).GetChild(15).GetChild(0).GetChild(0).gameObject;
Tests[7] = this.transform.GetChild(0).GetChild(1).GetChild(16).GetChild(0).GetChild(0).gameObject;
Tests[8] = this.transform.GetChild(0).GetChild(1).GetChild(17).GetChild(0).GetChild(0).gameObject;
Tests[9] = this.transform.GetChild(0).GetChild(1).GetChild(18).GetChild(0).GetChild(0).gameObject;
Tests[10] = this.transform.GetChild(0).GetChild(1).GetChild(19).GetChild(0).GetChild(0).gameObject;
Tests[11] = this.transform.GetChild(0).GetChild(1).GetChild(20).GetChild(0).GetChild(0).gameObject;
Tests[12] = this.transform.GetChild(0).GetChild(1).GetChild(21).GetChild(0).GetChild(0).gameObject;
Tests[13] = this.transform.GetChild(0).GetChild(1).GetChild(22).GetChild(0).GetChild(0).gameObject;
Tests[14] = this.transform.GetChild(0).GetChild(1).GetChild(23).GetChild(0).GetChild(0).gameObject;
Tests[15] = this.transform.GetChild(0).GetChild(1).GetChild(24).GetChild(0).GetChild(0).gameObject;
Tests[16] = this.transform.GetChild(0).GetChild(1).GetChild(25).GetChild(0).GetChild(0).gameObject;
Tests[17] = this.transform.GetChild(0).GetChild(1).GetChild(26).GetChild(0).GetChild(0).gameObject;
Tests[18] = this.transform.GetChild(0).GetChild(1).GetChild(27).GetChild(0).GetChild(0).gameObject;
Tests[19] = this.transform.GetChild(0).GetChild(1).GetChild(28).GetChild(0).GetChild(0).gameObject;
Tests[20] = this.transform.GetChild(0).GetChild(1).GetChild(29).GetChild(0).GetChild(0).gameObject;
Tests[21] = this.transform.GetChild(0).GetChild(1).GetChild(30).GetChild(0).GetChild(0).gameObject;
Tests[22] = this.transform.GetChild(0).GetChild(1).GetChild(31).GetChild(0).GetChild(0).gameObject;
Tests[23] = this.transform.GetChild(0).GetChild(1).GetChild(32).GetChild(0).GetChild(0).gameObject;
Tests[24] = this.transform.GetChild(0).GetChild(1).GetChild(33).GetChild(0).GetChild(0).gameObject;
Tests[25] = this.transform.GetChild(0).GetChild(1).GetChild(34).GetChild(0).GetChild(0).gameObject;
Tests[26] = this.transform.GetChild(0).GetChild(1).GetChild(35).GetChild(0).GetChild(0).gameObject;
Tests[27] = this.transform.GetChild(0).GetChild(1).GetChild(36).GetChild(0).GetChild(0).gameObject;
Tests[28] = this.transform.GetChild(0).GetChild(1).GetChild(37).GetChild(0).GetChild(0).gameObject;
//fog
FogEffect = this.gameObject.transform.GetChild(0).GetChild(2).GetChild(0).GetChild(2).gameObject;
}
}