Let's say I would like to add functionality to the OnSelect() Event of a dropdown element.
Normally I would just add a new script to the specific dropdown gameObject:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class LanguageDropdown : MonoBehaviour, ISelectHandler// required interface when using the OnSelect method.
{
//Do this when the selectable UI object is selected.
public void OnSelect(BaseEventData eventData)
{
Debug.Log(this.gameObject.name + " was selected");
}
}
Hint: The script simply outputs a message if the Dropdown is getting selected.
Question: Is it possible to define the functionality inside another script? E.g. I have a script attached to the master parent "Menue" where I am referencing this specific dropdown gameobject.
How can I define the OnSelect inside another script?
PS: Is this the correct place to ask this question, or should I ask it on gamedevelopement instead?


UnityEventand I was in a hurry. I think he saw that.