Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

GetComponentsInChildren<Transform> () don't work in function onclick event

Discussion in 'Editor & General Support' started by samusam, Jun 26, 2015.

  1. samusam

    samusam

    Joined:
    Mar 29, 2014
    Posts:
    48
    Hi,
    I have this code in a function call for onclick event:
    figli = GameObject.Find ("nuovaAnimazioneArisguard 3").GetComponentsInChildren<Transform> ();
    foreach (Transform child in figli) {

    if (child.tag == "oggetti interattivi") {
    print ("ok c'è l'oggetto");
    ES2.Save (progressoDrop [j].transform, nomeFile + "?tag=dropList" + j);
    inInventario [j] = true;
    ES2.Save (inInventario [j], nomeFile + "?tag=dropOkList" + j);
    j++;
    }
    }
    It is doesn't work, but if i put in update, it is works. I need put in onclick event. Where is my problem?
     
  2. samusam

    samusam

    Joined:
    Mar 29, 2014
    Posts:
    48
    there in in top code:
    if (j < 4) {
     
  3. samusam

    samusam

    Joined:
    Mar 29, 2014
    Posts:
    48
    Please, you respond me