forked from MattRix/UnityDecompiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToggleGroup.cs
More file actions
95 lines (84 loc) · 1.77 KB
/
Copy pathToggleGroup.cs
File metadata and controls
95 lines (84 loc) · 1.77 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
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine.EventSystems;
namespace UnityEngine.UI
{
[AddComponentMenu("UI/Toggle Group", 32), DisallowMultipleComponent]
public class ToggleGroup : UIBehaviour
{
[SerializeField]
private bool m_AllowSwitchOff = false;
private List<Toggle> m_Toggles = new List<Toggle>();
public bool allowSwitchOff
{
get
{
return this.m_AllowSwitchOff;
}
set
{
this.m_AllowSwitchOff = value;
}
}
protected ToggleGroup()
{
}
private void ValidateToggleIsInGroup(Toggle toggle)
{
if (toggle == null || !this.m_Toggles.Contains(toggle))
{
throw new ArgumentException(string.Format("Toggle {0} is not part of ToggleGroup {1}", new object[]
{
toggle,
this
}));
}
}
public void NotifyToggleOn(Toggle toggle)
{
this.ValidateToggleIsInGroup(toggle);
for (int i = 0; i < this.m_Toggles.Count; i++)
{
if (!(this.m_Toggles[i] == toggle))
{
this.m_Toggles[i].isOn = false;
}
}
}
public void UnregisterToggle(Toggle toggle)
{
if (this.m_Toggles.Contains(toggle))
{
this.m_Toggles.Remove(toggle);
}
}
public void RegisterToggle(Toggle toggle)
{
if (!this.m_Toggles.Contains(toggle))
{
this.m_Toggles.Add(toggle);
}
}
public bool AnyTogglesOn()
{
return this.m_Toggles.Find((Toggle x) => x.isOn) != null;
}
public IEnumerable<Toggle> ActiveToggles()
{
return from x in this.m_Toggles
where x.isOn
select x;
}
public void SetAllTogglesOff()
{
bool allowSwitchOff = this.m_AllowSwitchOff;
this.m_AllowSwitchOff = true;
for (int i = 0; i < this.m_Toggles.Count; i++)
{
this.m_Toggles[i].isOn = false;
}
this.m_AllowSwitchOff = allowSwitchOff;
}
}
}