dimanche 14 juin 2020

Unity enable/disable boolean while playing (editor)

Best method to listen when checkbox is enabled / disabled (in Unity Editor) ?

I want to enable and disable while running/playing scene

enter image description here

Maybe possible to toggle once and Editor could wait when i click again? I don't need every update scan list..

My code:

void Update () {
    checkboxStatus(visibleLocations, locationsList);
}

public void checkboxStatus(bool checkboxEnabled, List<GameObject> list)
{
    if (list.Count > 0) 
    {
        foreach (var item in list)
        {
            if (checkboxEnabled)
            {
                item.GetComponentInChildren<MeshRenderer>().enabled = true;
            }
            else
            {
                item.GetComponentInChildren<MeshRenderer>().enabled = false;
            }
        }
    }
}



Aucun commentaire:

Enregistrer un commentaire