Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
How to make one toggle turn off when the other turns on in unity

I am making a 2d game in unity. I am using the UI toggle methods and wish to make one of those turn off when the other one is turned on. The method I have tried is doing the following code below (InfiniteMode and CampaignMode are the names of the two toggles):

if (InfiniteMode.isOn)
    {
        PlayInfinite();
        CampaignMode.onValueChanged.Invoke(false);
    }

    if (CampaignMode.isOn)
    {
        PlayCampaign();
        InfiniteMode.onValueChanged.Invoke(false);
    }

Any help for what I can do to achieve this would be great.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

As far as I understand you want to have two UI Toggles which acts as a group, when one of them is on, the rest of the items are off. In order to do this you can use Toggle Group component from Unity UI. You can find more information on that here: Toggle Group documentation.

If you look at Toggle component there is a Group variable. If you create an empty GameObject inside your Canvas and add Toggle Group component to it and assign that Toggle Group object to all your Toggle's which you want to be a part of that group it should work.

over 4 years ago · Santiago Trujillo Denunciar

0

You can add listeners to your toggles like this:

[SerializeField]
private Toggle myToggleVar;

private void Start() {
    // UI event listeners
    myToggleVar.onValueChanged.AddListener(delegate { onToggleExec(); });
}

private void onToggleExec() {
    Debug.Log("Toggled!") //here you need to manipulate your other toggle
}
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda