A game about forced loneliness, made by TACStudios
1using System;
2using UnityEngine.UI;
3
4namespace Unity.VisualScripting
5{
6 /// <summary>
7 /// Called when the current value of the dropdown has changed.
8 /// </summary>
9 [UnitCategory("Events/GUI")]
10 [TypeIcon(typeof(Dropdown))]
11 [UnitOrder(4)]
12 public sealed class OnDropdownValueChanged : GameObjectEventUnit<int>
13 {
14 public override Type MessageListenerType => typeof(UnityOnDropdownValueChangedMessageListener);
15 protected override string hookName => EventHooks.OnDropdownValueChanged;
16
17 /// <summary>
18 /// The index of the newly selected option.
19 /// </summary>
20 [DoNotSerialize]
21 public ValueOutput index { get; private set; }
22
23 /// <summary>
24 /// The text of the newly selected option.
25 /// </summary>
26 [DoNotSerialize]
27 public ValueOutput text { get; private set; }
28
29 protected override void Definition()
30 {
31 base.Definition();
32
33 index = ValueOutput<int>(nameof(index));
34 text = ValueOutput<string>(nameof(text));
35 }
36
37 protected override void AssignArguments(Flow flow, int index)
38 {
39 flow.SetValue(this.index, index);
40 flow.SetValue(text, flow.GetValue<Dropdown>(target).options[index].text);
41 }
42 }
43}