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

113
Vistas
Custom onClick list

Can i create custom region with grouped methods for list onClick like dynamic and statics? like this

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

0

Yes and no! ^^

  • Yes, you can create your own event type taking a parameter and assign dynamic callbacks to it. What you are looking for is UnityEvent.

    For the dynamic parameterized ones see UnityEvent<T0> to UnityEvent<T0, T1, T2, T3> depending on how many parameters you need.

    For the example with a single int it would be (exactly as in the API example)

    // Since Unity doesn't support direct serialization of generics you have to implement this [Serializable] wrapper
    [Serializable]
    public class MyIntEvent : UnityEvent<int>
    {
    }
    
    public class ExampleClass : MonoBehaviour
    {
        public MyIntEvent m_MyEvent;
    }
    

    enter image description here

  • No, you can not simply change the existing implementation of UI.Button.onClick which is parameterless.

    What you could do, however, is build a new component and attach it on a button like

    [RequireComponent(typeof(Button))]
    public class ExampleClass : MonoBehaviour
    {
        [SerializeField] private Button _button;
        public MyIntEvent onClickWithIntParameter;
    
        private void Awake()
        {
            if(!_button) _button = GetComponent<Button>();
            _button.onClick.AddListener(HandleOnClick);
        }
    
        private void HandleOnClick()
        {
            // Wherever you get your int from
            var value = 123;
    
            onClickWithIntParameter.Invoke(value);
        }
    }
    
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