using System; using UnityEngine.UI; namespace Unity.VisualScripting { /// /// Called when the current value of the dropdown has changed. /// [UnitCategory("Events/GUI")] [TypeIcon(typeof(Dropdown))] [UnitOrder(4)] public sealed class OnDropdownValueChanged : GameObjectEventUnit { public override Type MessageListenerType => typeof(UnityOnDropdownValueChangedMessageListener); protected override string hookName => EventHooks.OnDropdownValueChanged; /// /// The index of the newly selected option. /// [DoNotSerialize] public ValueOutput index { get; private set; } /// /// The text of the newly selected option. /// [DoNotSerialize] public ValueOutput text { get; private set; } protected override void Definition() { base.Definition(); index = ValueOutput(nameof(index)); text = ValueOutput(nameof(text)); } protected override void AssignArguments(Flow flow, int index) { flow.SetValue(this.index, index); flow.SetValue(text, flow.GetValue(target).options[index].text); } } }