forked from hunterzonewu/unity-decompiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelectable.cs
More file actions
713 lines (659 loc) · 24.3 KB
/
Selectable.cs
File metadata and controls
713 lines (659 loc) · 24.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
// Decompiled with JetBrains decompiler
// Type: UnityEngine.UI.Selectable
// Assembly: UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 2216A18B-AF52-44A5-85A0-A1CAA19C1090
// Assembly location: C:\Users\Blake\sandbox\unity\test-project\Library\UnityAssemblies\UnityEngine.UI.dll
using System;
using System.Collections.Generic;
using UnityEngine.EventSystems;
using UnityEngine.Serialization;
namespace UnityEngine.UI
{
/// <summary>
/// <para>Simple selectable object - derived from to create a selectable control.</para>
/// </summary>
[ExecuteInEditMode]
[SelectionBase]
[AddComponentMenu("UI/Selectable", 70)]
[DisallowMultipleComponent]
public class Selectable : UIBehaviour, IEventSystemHandler, IPointerEnterHandler, IPointerExitHandler, IPointerDownHandler, IPointerUpHandler, ISelectHandler, IDeselectHandler, IMoveHandler
{
private static List<Selectable> s_List = new List<Selectable>();
[SerializeField]
[FormerlySerializedAs("navigation")]
private Navigation m_Navigation = Navigation.defaultNavigation;
[SerializeField]
[FormerlySerializedAs("transition")]
private Selectable.Transition m_Transition = Selectable.Transition.ColorTint;
[SerializeField]
[FormerlySerializedAs("colors")]
private ColorBlock m_Colors = ColorBlock.defaultColorBlock;
[SerializeField]
[FormerlySerializedAs("animationTriggers")]
private AnimationTriggers m_AnimationTriggers = new AnimationTriggers();
[SerializeField]
[Tooltip("Can the Selectable be interacted with?")]
private bool m_Interactable = true;
private bool m_GroupsAllowInteraction = true;
private readonly List<CanvasGroup> m_CanvasGroupCache = new List<CanvasGroup>();
[FormerlySerializedAs("spriteState")]
[SerializeField]
private SpriteState m_SpriteState;
[FormerlySerializedAs("highlightGraphic")]
[SerializeField]
[FormerlySerializedAs("m_HighlightGraphic")]
private Graphic m_TargetGraphic;
private Selectable.SelectionState m_CurrentSelectionState;
/// <summary>
/// <para>List of all the selectable objects currently active in the scene.</para>
/// </summary>
public static List<Selectable> allSelectables
{
get
{
return Selectable.s_List;
}
}
/// <summary>
/// <para>The Navigation setting for this selectable object.</para>
/// </summary>
public Navigation navigation
{
get
{
return this.m_Navigation;
}
set
{
if (!SetPropertyUtility.SetEquatableStruct<Navigation>(ref this.m_Navigation, value))
return;
this.OnSetProperty();
}
}
/// <summary>
/// <para>The type of transition that will be applied to the targetGraphic when the state changes.</para>
/// </summary>
public Selectable.Transition transition
{
get
{
return this.m_Transition;
}
set
{
if (!SetPropertyUtility.SetStruct<Selectable.Transition>(ref this.m_Transition, value))
return;
this.OnSetProperty();
}
}
/// <summary>
/// <para>The ColorBlock for this selectable object.</para>
/// </summary>
public ColorBlock colors
{
get
{
return this.m_Colors;
}
set
{
if (!SetPropertyUtility.SetEquatableStruct<ColorBlock>(ref this.m_Colors, value))
return;
this.OnSetProperty();
}
}
/// <summary>
/// <para>The SpriteState for this selectable object.</para>
/// </summary>
public SpriteState spriteState
{
get
{
return this.m_SpriteState;
}
set
{
if (!SetPropertyUtility.SetEquatableStruct<SpriteState>(ref this.m_SpriteState, value))
return;
this.OnSetProperty();
}
}
/// <summary>
/// <para>The AnimationTriggers for this selectable object.</para>
/// </summary>
public AnimationTriggers animationTriggers
{
get
{
return this.m_AnimationTriggers;
}
set
{
if (!SetPropertyUtility.SetClass<AnimationTriggers>(ref this.m_AnimationTriggers, value))
return;
this.OnSetProperty();
}
}
/// <summary>
/// <para>Graphic that will be transitioned upon.</para>
/// </summary>
public Graphic targetGraphic
{
get
{
return this.m_TargetGraphic;
}
set
{
if (!SetPropertyUtility.SetClass<Graphic>(ref this.m_TargetGraphic, value))
return;
this.OnSetProperty();
}
}
/// <summary>
/// <para>UI.Selectable.interactable.</para>
/// </summary>
public bool interactable
{
get
{
return this.m_Interactable;
}
set
{
if (!SetPropertyUtility.SetStruct<bool>(ref this.m_Interactable, value))
return;
if (this.m_Interactable && (UnityEngine.Object) EventSystem.current != (UnityEngine.Object) null && (UnityEngine.Object) EventSystem.current.currentSelectedGameObject == (UnityEngine.Object) this.gameObject)
EventSystem.current.SetSelectedGameObject((GameObject) null);
this.OnSetProperty();
}
}
private bool isPointerInside { get; set; }
private bool isPointerDown { get; set; }
private bool hasSelection { get; set; }
/// <summary>
/// <para>Convenience function that converts the referenced Graphic to a Image, if possible.</para>
/// </summary>
public Image image
{
get
{
return this.m_TargetGraphic as Image;
}
set
{
this.m_TargetGraphic = (Graphic) value;
}
}
/// <summary>
/// <para>Convenience function to get the Animator component on the GameObject.</para>
/// </summary>
public Animator animator
{
get
{
return this.GetComponent<Animator>();
}
}
protected Selectable.SelectionState currentSelectionState
{
get
{
return this.m_CurrentSelectionState;
}
}
protected Selectable()
{
}
protected override void Awake()
{
if (!((UnityEngine.Object) this.m_TargetGraphic == (UnityEngine.Object) null))
return;
this.m_TargetGraphic = this.GetComponent<Graphic>();
}
protected override void OnCanvasGroupChanged()
{
bool flag1 = true;
for (Transform transform = this.transform; (UnityEngine.Object) transform != (UnityEngine.Object) null; transform = transform.parent)
{
transform.GetComponents<CanvasGroup>(this.m_CanvasGroupCache);
bool flag2 = false;
for (int index = 0; index < this.m_CanvasGroupCache.Count; ++index)
{
if (!this.m_CanvasGroupCache[index].interactable)
{
flag1 = false;
flag2 = true;
}
if (this.m_CanvasGroupCache[index].ignoreParentGroups)
flag2 = true;
}
if (flag2)
break;
}
if (flag1 == this.m_GroupsAllowInteraction)
return;
this.m_GroupsAllowInteraction = flag1;
this.OnSetProperty();
}
/// <summary>
/// <para>UI.Selectable.IsInteractable.</para>
/// </summary>
public virtual bool IsInteractable()
{
if (this.m_GroupsAllowInteraction)
return this.m_Interactable;
return false;
}
protected override void OnDidApplyAnimationProperties()
{
this.OnSetProperty();
}
protected override void OnEnable()
{
base.OnEnable();
Selectable.s_List.Add(this);
Selectable.SelectionState selectionState = Selectable.SelectionState.Normal;
if (this.hasSelection)
selectionState = Selectable.SelectionState.Highlighted;
this.m_CurrentSelectionState = selectionState;
this.InternalEvaluateAndTransitionToSelectionState(true);
}
private void OnSetProperty()
{
if (!Application.isPlaying)
this.InternalEvaluateAndTransitionToSelectionState(true);
else
this.InternalEvaluateAndTransitionToSelectionState(false);
}
/// <summary>
/// <para>See MonoBehaviour.OnDisable.</para>
/// </summary>
protected override void OnDisable()
{
Selectable.s_List.Remove(this);
this.InstantClearState();
base.OnDisable();
}
protected override void OnValidate()
{
base.OnValidate();
this.m_Colors.fadeDuration = Mathf.Max(this.m_Colors.fadeDuration, 0.0f);
if (!this.isActiveAndEnabled)
return;
if (!this.interactable && (UnityEngine.Object) EventSystem.current != (UnityEngine.Object) null && (UnityEngine.Object) EventSystem.current.currentSelectedGameObject == (UnityEngine.Object) this.gameObject)
EventSystem.current.SetSelectedGameObject((GameObject) null);
this.DoSpriteSwap((Sprite) null);
this.StartColorTween(Color.white, true);
this.TriggerAnimation(this.m_AnimationTriggers.normalTrigger);
this.InternalEvaluateAndTransitionToSelectionState(true);
}
protected override void Reset()
{
this.m_TargetGraphic = this.GetComponent<Graphic>();
}
/// <summary>
/// <para>Clear any internal state from the Selectable (used when disabling).</para>
/// </summary>
protected virtual void InstantClearState()
{
string normalTrigger = this.m_AnimationTriggers.normalTrigger;
this.isPointerInside = false;
this.isPointerDown = false;
this.hasSelection = false;
switch (this.m_Transition)
{
case Selectable.Transition.ColorTint:
this.StartColorTween(Color.white, true);
break;
case Selectable.Transition.SpriteSwap:
this.DoSpriteSwap((Sprite) null);
break;
case Selectable.Transition.Animation:
this.TriggerAnimation(normalTrigger);
break;
}
}
protected virtual void DoStateTransition(Selectable.SelectionState state, bool instant)
{
Color color;
Sprite newSprite;
string triggername;
switch (state)
{
case Selectable.SelectionState.Normal:
color = this.m_Colors.normalColor;
newSprite = (Sprite) null;
triggername = this.m_AnimationTriggers.normalTrigger;
break;
case Selectable.SelectionState.Highlighted:
color = this.m_Colors.highlightedColor;
newSprite = this.m_SpriteState.highlightedSprite;
triggername = this.m_AnimationTriggers.highlightedTrigger;
break;
case Selectable.SelectionState.Pressed:
color = this.m_Colors.pressedColor;
newSprite = this.m_SpriteState.pressedSprite;
triggername = this.m_AnimationTriggers.pressedTrigger;
break;
case Selectable.SelectionState.Disabled:
color = this.m_Colors.disabledColor;
newSprite = this.m_SpriteState.disabledSprite;
triggername = this.m_AnimationTriggers.disabledTrigger;
break;
default:
color = Color.black;
newSprite = (Sprite) null;
triggername = string.Empty;
break;
}
if (!this.gameObject.activeInHierarchy)
return;
switch (this.m_Transition)
{
case Selectable.Transition.ColorTint:
this.StartColorTween(color * this.m_Colors.colorMultiplier, instant);
break;
case Selectable.Transition.SpriteSwap:
this.DoSpriteSwap(newSprite);
break;
case Selectable.Transition.Animation:
this.TriggerAnimation(triggername);
break;
}
}
/// <summary>
/// <para>Finds the selectable object next to this one.</para>
/// </summary>
/// <param name="dir">The direction in which to search for a neighbouring Selectable object.</param>
/// <returns>
/// <para>The neighbouring Selectable object. Null if none found.</para>
/// </returns>
public Selectable FindSelectable(Vector3 dir)
{
dir = dir.normalized;
Vector3 vector3 = this.transform.TransformPoint(Selectable.GetPointOnRectEdge(this.transform as RectTransform, (Vector2) (Quaternion.Inverse(this.transform.rotation) * dir)));
float num1 = float.NegativeInfinity;
Selectable selectable1 = (Selectable) null;
for (int index = 0; index < Selectable.s_List.Count; ++index)
{
Selectable selectable2 = Selectable.s_List[index];
if (!((UnityEngine.Object) selectable2 == (UnityEngine.Object) this) && !((UnityEngine.Object) selectable2 == (UnityEngine.Object) null) && selectable2.IsInteractable() && selectable2.navigation.mode != Navigation.Mode.None)
{
RectTransform transform = selectable2.transform as RectTransform;
Vector3 position = !((UnityEngine.Object) transform != (UnityEngine.Object) null) ? Vector3.zero : (Vector3) transform.rect.center;
Vector3 rhs = selectable2.transform.TransformPoint(position) - vector3;
float num2 = Vector3.Dot(dir, rhs);
if ((double) num2 > 0.0)
{
float num3 = num2 / rhs.sqrMagnitude;
if ((double) num3 > (double) num1)
{
num1 = num3;
selectable1 = selectable2;
}
}
}
}
return selectable1;
}
private static Vector3 GetPointOnRectEdge(RectTransform rect, Vector2 dir)
{
if ((UnityEngine.Object) rect == (UnityEngine.Object) null)
return Vector3.zero;
if (dir != Vector2.zero)
dir /= Mathf.Max(Mathf.Abs(dir.x), Mathf.Abs(dir.y));
dir = rect.rect.center + Vector2.Scale(rect.rect.size, dir * 0.5f);
return (Vector3) dir;
}
private void Navigate(AxisEventData eventData, Selectable sel)
{
if (!((UnityEngine.Object) sel != (UnityEngine.Object) null) || !sel.IsActive())
return;
eventData.selectedObject = sel.gameObject;
}
/// <summary>
/// <para>Find the selectable object to the left of this one.</para>
/// </summary>
/// <returns>
/// <para>The Selectable object to the left of current.</para>
/// </returns>
public virtual Selectable FindSelectableOnLeft()
{
if (this.m_Navigation.mode == Navigation.Mode.Explicit)
return this.m_Navigation.selectOnLeft;
if ((this.m_Navigation.mode & Navigation.Mode.Horizontal) != Navigation.Mode.None)
return this.FindSelectable(this.transform.rotation * Vector3.left);
return (Selectable) null;
}
/// <summary>
/// <para>Find the selectable object to the right of this one.</para>
/// </summary>
/// <returns>
/// <para>The Selectable object to the right of current.</para>
/// </returns>
public virtual Selectable FindSelectableOnRight()
{
if (this.m_Navigation.mode == Navigation.Mode.Explicit)
return this.m_Navigation.selectOnRight;
if ((this.m_Navigation.mode & Navigation.Mode.Horizontal) != Navigation.Mode.None)
return this.FindSelectable(this.transform.rotation * Vector3.right);
return (Selectable) null;
}
/// <summary>
/// <para>Find the selectable object above this one.</para>
/// </summary>
/// <returns>
/// <para>The Selectable object above current.</para>
/// </returns>
public virtual Selectable FindSelectableOnUp()
{
if (this.m_Navigation.mode == Navigation.Mode.Explicit)
return this.m_Navigation.selectOnUp;
if ((this.m_Navigation.mode & Navigation.Mode.Vertical) != Navigation.Mode.None)
return this.FindSelectable(this.transform.rotation * Vector3.up);
return (Selectable) null;
}
/// <summary>
/// <para>Find the selectable object below this one.</para>
/// </summary>
/// <returns>
/// <para>The Selectable object below current.</para>
/// </returns>
public virtual Selectable FindSelectableOnDown()
{
if (this.m_Navigation.mode == Navigation.Mode.Explicit)
return this.m_Navigation.selectOnDown;
if ((this.m_Navigation.mode & Navigation.Mode.Vertical) != Navigation.Mode.None)
return this.FindSelectable(this.transform.rotation * Vector3.down);
return (Selectable) null;
}
/// <summary>
/// <para>Determine in which of the 4 move directions the next selectable object should be found.</para>
/// </summary>
/// <param name="eventData">The EventData usually sent by the EventSystem.</param>
public virtual void OnMove(AxisEventData eventData)
{
switch (eventData.moveDir)
{
case MoveDirection.Left:
this.Navigate(eventData, this.FindSelectableOnLeft());
break;
case MoveDirection.Up:
this.Navigate(eventData, this.FindSelectableOnUp());
break;
case MoveDirection.Right:
this.Navigate(eventData, this.FindSelectableOnRight());
break;
case MoveDirection.Down:
this.Navigate(eventData, this.FindSelectableOnDown());
break;
}
}
private void StartColorTween(Color targetColor, bool instant)
{
if ((UnityEngine.Object) this.m_TargetGraphic == (UnityEngine.Object) null)
return;
this.m_TargetGraphic.CrossFadeColor(targetColor, !instant ? this.m_Colors.fadeDuration : 0.0f, true, true);
}
private void DoSpriteSwap(Sprite newSprite)
{
if ((UnityEngine.Object) this.image == (UnityEngine.Object) null)
return;
this.image.overrideSprite = newSprite;
}
private void TriggerAnimation(string triggername)
{
if ((UnityEngine.Object) this.animator == (UnityEngine.Object) null || !this.animator.isActiveAndEnabled || ((UnityEngine.Object) this.animator.runtimeAnimatorController == (UnityEngine.Object) null || string.IsNullOrEmpty(triggername)))
return;
this.animator.ResetTrigger(this.m_AnimationTriggers.normalTrigger);
this.animator.ResetTrigger(this.m_AnimationTriggers.pressedTrigger);
this.animator.ResetTrigger(this.m_AnimationTriggers.highlightedTrigger);
this.animator.ResetTrigger(this.m_AnimationTriggers.disabledTrigger);
this.animator.SetTrigger(triggername);
}
/// <summary>
/// <para>Is the selectable currently 'highlighted'.</para>
/// </summary>
/// <param name="eventData"></param>
protected bool IsHighlighted(BaseEventData eventData)
{
if (!this.IsActive() || this.IsPressed())
return false;
bool hasSelection = this.hasSelection;
bool flag;
if (eventData is PointerEventData)
{
PointerEventData pointerEventData = eventData as PointerEventData;
flag = ((hasSelection ? 1 : 0) | (this.isPointerDown && !this.isPointerInside && (UnityEngine.Object) pointerEventData.pointerPress == (UnityEngine.Object) this.gameObject || !this.isPointerDown && this.isPointerInside && (UnityEngine.Object) pointerEventData.pointerPress == (UnityEngine.Object) this.gameObject ? 1 : (this.isPointerDown || !this.isPointerInside ? 0 : ((UnityEngine.Object) pointerEventData.pointerPress == (UnityEngine.Object) null ? 1 : 0)))) != 0;
}
else
flag = hasSelection | this.isPointerInside;
return flag;
}
[Obsolete("Is Pressed no longer requires eventData", false)]
protected bool IsPressed(BaseEventData eventData)
{
return this.IsPressed();
}
protected bool IsPressed()
{
if (!this.IsActive() || !this.isPointerInside)
return false;
return this.isPointerDown;
}
/// <summary>
/// <para>Internally update the selection state of the Selectable.</para>
/// </summary>
/// <param name="eventData"></param>
protected void UpdateSelectionState(BaseEventData eventData)
{
if (this.IsPressed())
this.m_CurrentSelectionState = Selectable.SelectionState.Pressed;
else if (this.IsHighlighted(eventData))
this.m_CurrentSelectionState = Selectable.SelectionState.Highlighted;
else
this.m_CurrentSelectionState = Selectable.SelectionState.Normal;
}
private void EvaluateAndTransitionToSelectionState(BaseEventData eventData)
{
if (!this.IsActive())
return;
this.UpdateSelectionState(eventData);
this.InternalEvaluateAndTransitionToSelectionState(false);
}
private void InternalEvaluateAndTransitionToSelectionState(bool instant)
{
Selectable.SelectionState state = this.m_CurrentSelectionState;
if (this.IsActive() && !this.IsInteractable())
state = Selectable.SelectionState.Disabled;
this.DoStateTransition(state, instant);
}
/// <summary>
/// <para>Evaluate current state and transition to pressed state.</para>
/// </summary>
/// <param name="eventData">The EventData usually sent by the EventSystem.</param>
public virtual void OnPointerDown(PointerEventData eventData)
{
if (eventData.button != PointerEventData.InputButton.Left)
return;
if (this.IsInteractable() && (this.navigation.mode != Navigation.Mode.None && (UnityEngine.Object) EventSystem.current != (UnityEngine.Object) null))
EventSystem.current.SetSelectedGameObject(this.gameObject, (BaseEventData) eventData);
this.isPointerDown = true;
this.EvaluateAndTransitionToSelectionState((BaseEventData) eventData);
}
/// <summary>
/// <para>Evaluate eventData and transition to appropriate state.</para>
/// </summary>
/// <param name="eventData">The EventData usually sent by the EventSystem.</param>
public virtual void OnPointerUp(PointerEventData eventData)
{
if (eventData.button != PointerEventData.InputButton.Left)
return;
this.isPointerDown = false;
this.EvaluateAndTransitionToSelectionState((BaseEventData) eventData);
}
/// <summary>
/// <para>Evaluate current state and transition to appropriate state.</para>
/// </summary>
/// <param name="eventData">The EventData usually sent by the EventSystem.</param>
public virtual void OnPointerEnter(PointerEventData eventData)
{
this.isPointerInside = true;
this.EvaluateAndTransitionToSelectionState((BaseEventData) eventData);
}
/// <summary>
/// <para>Evaluate current state and transition to normal state.</para>
/// </summary>
/// <param name="eventData">The EventData usually sent by the EventSystem.</param>
public virtual void OnPointerExit(PointerEventData eventData)
{
this.isPointerInside = false;
this.EvaluateAndTransitionToSelectionState((BaseEventData) eventData);
}
/// <summary>
/// <para>Set selection and transition to appropriate state.</para>
/// </summary>
/// <param name="eventData">The EventData usually sent by the EventSystem.</param>
public virtual void OnSelect(BaseEventData eventData)
{
this.hasSelection = true;
this.EvaluateAndTransitionToSelectionState(eventData);
}
/// <summary>
/// <para>Unset selection and transition to appropriate state.</para>
/// </summary>
/// <param name="eventData">The eventData usually sent by the EventSystem.</param>
public virtual void OnDeselect(BaseEventData eventData)
{
this.hasSelection = false;
this.EvaluateAndTransitionToSelectionState(eventData);
}
/// <summary>
/// <para>Selects this Selectable.</para>
/// </summary>
public virtual void Select()
{
if ((UnityEngine.Object) EventSystem.current == (UnityEngine.Object) null || EventSystem.current.alreadySelecting)
return;
EventSystem.current.SetSelectedGameObject(this.gameObject);
}
/// <summary>
/// <para>Transition mode for a Selectable.</para>
/// </summary>
public enum Transition
{
None,
ColorTint,
SpriteSwap,
Animation,
}
protected enum SelectionState
{
Normal,
Highlighted,
Pressed,
Disabled,
}
}
}