OLD_STEP_LIST_EDITOR
Documentation for the Unity C# Library
Loading...
Searching...
No Matches
AnswerOption.cs
Go to the documentation of this file.
1
using
System;
2
using
TMPro;
3
using
UnityEngine;
4
using
UnityEngine.UI;
5
6
namespace
PixoVR.Vrinput
7
{
8
public
class
AnswerOption
: MonoBehaviour
9
{
10
[SerializeField]
private
TMP_Text
answerOption
;
11
[SerializeField]
private
Toggle
toggle
;
12
[SerializeField]
private
bool
isAnswerCorrect
;
13
public
int
toggleID
;
14
15
public
event
Action<string, bool, int>
ToggleSelected
;
16
17
private
bool
_isSelected
;
18
19
private
void
Start
()
20
{
21
toggle
= GetComponent<Toggle>();
22
}
23
24
private
void
OnEnable
()
25
{
26
toggle
.onValueChanged.AddListener(
OnToggleSelected
);
27
}
28
29
private
void
OnDisable
()
30
{
31
toggle
.onValueChanged.RemoveListener(
OnToggleSelected
);
32
}
33
34
private
void
OnToggleSelected
(
bool
isSelected)
35
{
36
if
(!
_isSelected
)
37
{
38
_isSelected
= isSelected;
39
SetTextColor
(isSelected);
40
ToggleSelected
?.Invoke(
answerOption
.text,
isAnswerCorrect
,
toggleID
);
41
}
42
else
43
{
44
toggle
.SetIsOnWithoutNotify(
true
);
45
}
46
}
47
48
public
void
SetSelected
(
bool
isSelected)
49
{
50
_isSelected
= isSelected;
51
toggle
.SetIsOnWithoutNotify(isSelected);
52
SetTextColor
(isSelected);
53
}
54
55
public
void
SetText
(
string
option)
56
{
57
answerOption.text = option;
58
}
59
60
public
void
SetCorrectnes
(
bool
isCorrect)
61
{
62
isAnswerCorrect
= isCorrect;
63
}
64
65
private
void
SetTextColor
(
bool
isSelected)
66
{
67
answerOption.color = isSelected ? Color.white : Color.black;
68
}
69
}
70
}
PixoVR.Vrinput.AnswerOption
Definition
AnswerOption.cs:9
PixoVR.Vrinput.AnswerOption.SetCorrectnes
void SetCorrectnes(bool isCorrect)
Definition
AnswerOption.cs:69
PixoVR.Vrinput.AnswerOption.answerOption
TMP_Text answerOption
[SerializeField]
Definition
AnswerOption.cs:13
PixoVR.Vrinput.AnswerOption.SetText
void SetText(string option)
Definition
AnswerOption.cs:64
PixoVR.Vrinput.AnswerOption._isSelected
bool _isSelected
Definition
AnswerOption.cs:26
PixoVR.Vrinput.AnswerOption.SetSelected
void SetSelected(bool isSelected)
Definition
AnswerOption.cs:57
PixoVR.Vrinput.AnswerOption.toggleID
int toggleID
Definition
AnswerOption.cs:22
PixoVR.Vrinput.AnswerOption.OnDisable
void OnDisable()
Definition
AnswerOption.cs:38
PixoVR.Vrinput.AnswerOption.toggle
Toggle toggle
[SerializeField]
Definition
AnswerOption.cs:17
PixoVR.Vrinput.AnswerOption.Start
void Start()
Definition
AnswerOption.cs:28
PixoVR.Vrinput.AnswerOption.SetTextColor
void SetTextColor(bool isSelected)
Definition
AnswerOption.cs:74
PixoVR.Vrinput.AnswerOption.isAnswerCorrect
bool isAnswerCorrect
[SerializeField]
Definition
AnswerOption.cs:21
PixoVR.Vrinput.AnswerOption.OnToggleSelected
void OnToggleSelected(bool isSelected)
Definition
AnswerOption.cs:43
PixoVR.Vrinput.AnswerOption.OnEnable
void OnEnable()
Definition
AnswerOption.cs:33
PixoVR.Vrinput.AnswerOption.ToggleSelected
Action< string, bool, int > ToggleSelected
Definition
AnswerOption.cs:24
PixoVR.Vrinput
Definition
AnswerOption.cs:7
com.pixovr.eventunitysdk
Runtime
Sdk
Scripts
QuizScripts
AnswerOption.cs
Generated
Wed Oct 9 2024 19:24:03
by Doxygen version
1.10.0