-
-
Notifications
You must be signed in to change notification settings - Fork 2
Quiz Button
class in ExPresSXR.Experimentation / Extends UnityEngine.XR.Interaction.Toolkit.XRBaseInteractable
GameObject instantiable via ExPresSXR/Buttons/...
An expansion of BaseButton
representing the Button that is used when answering a TutorialButtonQuiz
.
It is able to display answer options in the form of text and GameObject that will hover above the press anchor.
In order to display the GameObjects it is advised to create a Prefab.
Also move them a bit up on the y-axis and if they should be made interactable add a XRGrabInteractable
to it.
Most logic is restricted to non-Toggle-Mode as Toggle-Mode is used when the quiz is in MultipleChoice-Mode. If in MultipleChoice-Mode the button will be automatically set to Toggle-Mode and the feedback is handled via an extra (See McConfirmButton
).
When pressed the events OnPressedCorrect
and OnPressedIncorrect
are invoked to notify if the button was pressed correctly or not.
-
PutBackSocketInteractor feedbackObjectSocket
: Socket to hold an answer object prefab. Adding aXRGrabInteractable
-Component to the_answerObject
will make it interactable.
This will instantiate a new GameObject, so prefabs are recommended as normal GameObjects will be duplicated. -
Text _feedbackTextLabel
: Reference to aText
-GameObject that is used to display the answer texts.
-
bool correctChoice
: If the question currently displayed is correct. -
bool feedbackDisabled
: If feedback should be given when pressing the button. -
bool invertedFeedback
: If the feedback should be inverted (if feedback is given). -
string answerText
: The string displayed as the answer. -
GameObject answerObject
: The prefab that is attached to thefeedbackObjectSocket
as answer option. -
bool _overrideInputDisabledEvents
: Used to not emit inputDisabled Events after an answer was given. -
AudioClip answeredCorrectSound
: Sound played when the button pressed with a correct answer. -
AudioClip answeredIncorrectSound
: Sound played when the button pressed with an incorrect answer. -
AudioSource _answerFeedbackAudioPlayer
: Audio Source used to playansweredCorrectSound
andansweredCorrectSound
. This prevents interferences with pressed/released sounds when answering.
-
void RestartTriggerTimer()
: Resets the timer measuring the time until the button was pressed to give an answer. Will be automatically called when displaying a new answer (DisplayAnswer()
is called). -
float GetTriggerTimerValue()
: The time in milliseconds since the last reset of the trigger timer. -
void DisplayAnswer(string answerText, GameObject answerObject, bool correctChoice)
: Displays a new question using the given parameters and resets the trigger timer. -
void ClearAnswer()
: Removes the text and GameObject from the button and moves the button back in up position. -
bool GiveMultipleChoiceFeedback()
: Used check if the button was correctly toggled when the quiz is in MultipleChoice-Mode. This only is when the button is in ToggleMode, if notfalse
will be returned.
-
void NotifyChoice()
: Invokes the events to notify about an answer given. Can be overwritten is the feedback should be gathered differently, a call tobase.NotifyChoice()
is not necessary. -
DisplayAnswer(string answerText, GameObject answerObject, bool correctChoice)
: Displays an answer using the provided information and removes the old one.
If no information is provided will disable the button. This may only happen during differing-answers-multiple-choice-quizzes. -
virtual void NotifyChoice()
: Emits events based on the feedback type to notify the user if the answer was correct. -
bool GiveMultipleChoiceFeedback()
: Used to find out if the button was toggled correct for a multiple choice quiz. -
void PlayAnsweredCorrectSound()
: Plays theansweredCorrectSound
, if assigned. -
void PlayAnsweredIncorrectSound()
: Plays theansweredIncorrectSound
, if assigned.
-
OnPressedCorrect
: Invoked viaNotifyChoice()
when the button was pressed (in non-ToggleMode) and the answer was correct. -
OnPressedIncorrect
: Invoked viaNotifyChoice()
when the button was pressed (in non-ToggleMode) and the answer was not correct.
-
void Start()
: Connects additional events. -
void InternalEmitInputDisabledEvents()
: Calls the base function only if not disabled via_overrideInputDisabledEvents
.
Autor: Luca 'eisclimber' Dreiling; License: MIT
- Getting Started
- Development and Contribution
- Misc
- Experimentation
- Data Gatherering
- Eye Tracking
- ExPresS XR Rig
- Interaction
- Base Button
- Button Quiz
- Collision Hand Rumbler
- Collision Sound Emitter
- Exit Game Interactable (Script Deprecated)
- Interactables
- Haptic Impulse Trigger
- Socket Interactors
- Inverse Kinematics
- Localization
- Minigames
- Coin Scale
- Coin Throw
- Sword Cleaning
- Misc
- Movement
- Presentation
- UI