Question Action¶
This type is described as an action expecting the user to make a decision on choices that answer a specific question. Answers are expected to be sprites on a Button gameObject.
Choosing a wrong answer does not perform the action, but registers the selection as wrong. When the correct answer is selected, the action performs after 5 seconds.
Example of Question Action:
/// <summary>
/// This is an example of Question Action
/// In this Action users are asked a question and they need to answer to complete the Action
/// The developer can set multiple answers by modifying the question prefab. In this example we have two answers
/// </summary>
public class QuestionActionExample : QuestionAction
{
/// <summary>
/// Initialize() method overrides base.Initialize and sets the question prefab
/// </summary>
public override void Initialize()
{
//Sets the question prefab that will spawn
SetQuestionPrefab("Lesson0/Stage0/Action1/QuestionPRefabExample");
//This method enables the raycast so users can answer using their controllers
InterfaceManagement.Get.InterfaceRaycastActivation(true);
base.Initialize();
}
}
Action Script Explanation¶
SetQuestionPrefab ⇒ Spawns the Action prefab containing the question to be answered. Has two arguments:
1.1. The prefab to be spawned
1.2. The Question itself (expected type: string)
AddAnswerImage ⇒ Spawns the Answer gameObject. Automatically attached onto the question Canvas.