Exemplo n.º 1
0
        public override void Invoke()
        {
            myData = (MultipleChoiceData)Event;

            MultipleChoiceOption question = Instantiate(QuestionPrefab, transform);

            question.SetText(myData.Question);

            for (int i = 0; i < myData.Answers.Length; i++)
            {
                string answer = myData.Answers[i];
                MultipleChoiceOption option = Instantiate(ChoicePrefab, transform);
                option.SetText(answer);
                option.Index    = i;
                option.OnClick += OnClick;
            }

            GridLayoutGroup3D layoutGroup3D = GetComponent <GridLayoutGroup3D>();

            layoutGroup3D.ForceUpdate();

            // TODO: For some reason the object spawns at an offset. Needs fixin!
            //Debug.Log(TransformSingleton.Instance);
            Transform orientation = TransformSingleton.Instance ?? Camera.main.transform;

            transform.rotation  = orientation.rotation;
            transform.position += orientation.forward * CameraDistance + (Vector3.up * layoutGroup3D.Spacing.Y * myData.Answers.Length / 2);
            //Debug.DrawRay(orientation.position, orientation.forward, Color.red, CameraDistance);
            //Debug.DrawLine(orientation.position, orientation.forward * CameraDistance + (Vector3.up * layoutGroup3D.Spacing.Y * myData.Answers.Length / 2), Color.red, 10);

            (TimelineController.Instance as TimelineExecuter).TogglePause(true);
        }
Exemplo n.º 2
0
    public void ProcessEvent(MultipleChoiceEvent e, MultipleChoiceEventProcessor eventManager)
    {
        var choices = e.GetClosestOptions(Constants.DefaultChoicesCount);

        for (int i = 0; i < choices.Count; ++i)
        {
            GameObject choiceGameObject = Instantiate(MultipleChoiceButtonPrefab);
            choiceGameObject.SetActive(true);
            choiceGameObject.transform.SetParent(transform, true);

            MultipleChoiceData multipleChoiceData = choiceGameObject.GetComponent <MultipleChoiceData>();
            multipleChoiceData.SetEvent(choices[i], eventManager);

            if (choiceGameObject.GetComponentsInChildren <Text>().Length > 0)
            {
                choiceGameObject.GetComponentsInChildren <Text>()[0].text = e.Choices[i].ChoiceText;
            }

            _choiceGameObjects.Add(choiceGameObject);
        }
    }