Ejemplo n.º 1
0
 /**
  * OnGUI code
  */
 void OnGUI()
 {
     if (showFeedback)
     {
         lookCloselyGUI.OnGUI(gameObject);
         model.guiOn = true;
     }
     else
     {
         if (ARModel.selected == gameObject)
         {
             if (model.Processed)
             {
                 //alreadyExaminedGUI.OnGUI(gameObject);
                 ARModel.selected = null;
                 model.guiOn      = false;
             }
             else
             {
                 gui.OnGUI(gameObject);
                 model.guiOn = true;
             }
         }
         else
         {
             model.guiOn = false;
         }
     }
 }
    public void OnGUI(GameObject gameObject)
    {
        if (CurrentSlide().GetSlideState() == Slide.SlideState.AR)
        {
            guiNoBackground.OnGUI(gameObject);
        }
        else
        {
            gui.OnGUI(gameObject);
        }


        CurrentSlide().OnGUI(gameObject);
    }
Ejemplo n.º 3
0
    void OnGUI()
    {
        if (FlowControl.MenuState)
        {
            GUI.enabled = false;
        }

        gui.OnGUI(gameObject);

        if (FlowControl.MenuState)
        {
            GUI.enabled = true;
        }

        if (FlowControl.MenuState)
        {
            FlowControl.DrawMenu(gameObject);
        }
    }
    public void DoGUI(GameObject gameObject)
    {
        switch (this.state)
        {
        case SlideState.AR:
            this.experience.OnGUI(gameObject);

            // Check if we have found a target!
            GameObject         targetGameObject    = this.experience.GetTarget();
            bool               found               = false;
            TrackableBehaviour mTrackableBehaviour = targetGameObject.GetComponent <TrackableBehaviour> ();

            ImageTargetAbstractBehaviour b = this.experience.GetTarget().GetComponent <ImageTargetAbstractBehaviour> ();
            if (b != null && b.ImageTarget != null)
            {
                String name = b.ImageTarget.Name;

                foreach (GameObject o in this.experience.GetGameObjects())
                {
                    foreach (Renderer component in targetGameObject.GetComponentsInChildren <Renderer>(true))
                    {
                        if (component.enabled && mTrackableBehaviour.TrackableName == name)
                        {
                            found = true;
                        }
                    }

                    foreach (Collider component in targetGameObject.GetComponentsInChildren <Collider>(true))
                    {
                        if (component.enabled && mTrackableBehaviour.TrackableName == name)
                        {
                            found = true;
                        }
                    }
                }
            }

            // If NOT found, show GUI text
            if (!found)
            {
                GUIFactory factory = new GUIFactory();
                factory.CreateLabel(this.text)
                .SetBox(new Box()
                        .SetMarginTop(0.01f)
                        .SetMarginLeft(0.3f)
                        .SetMarginRight(0.3f)
                        .SetHeight(0.1f));

                factory.Build().OnGUI(gameObject);
            }

            break;

        case SlideState.QUESTION:
            // ------------------- Construct GUI for Question ---------------------- \\

            // -------------------------------- QUESTION GUI --------------------------------- \\
            GUIFactory qFactory = new GUIFactory();

            // Go Back Button
            GUIButton backButton = new GUIButton();

            backButton.SetText("Go Back");
            backButton.SetBox(new Box()
                              .SetMarginTop("auto")
                              .SetMarginRight("auto")
                              .SetMarginLeft(0.01f)
                              .SetMarginBottom(0.01f)
                              .SetWidth(Screen.width * 0.2 + "px")
                              .SetHeight(0.1f));

            backButton.OnClick(FlowControl.PreviousSlide);

            GUIComponent c;
            if (this.showDescriptionOfRightAnswer)
            {
                c = new GUILabel(question.GetDescriptionOfRightAnswer());
                qFactory.Append(c);
                c.SetBox((new Box())
                         .SetMarginTop(0.1f)
                         .SetMarginRight(0.1f)
                         .SetMarginBottom(0.1f)
                         .SetMarginLeft(0.1f));

                GUILabel z = (GUILabel)c;
                z.SetStyle(GUIStyles.GetInstance().DEFAULT_SLIDE_STYLE);

                GUIButton continueButton = new GUIButton();
                continueButton.SetText("Continue");
                continueButton.SetBox(new Box()
                                      .SetMarginTop("auto")
                                      .SetMarginLeft("auto")
                                      .SetMarginRight(0.01f)
                                      .SetMarginBottom(0.01f)
                                      .SetWidth(Screen.width * 0.2 + "px")
                                      .SetHeight(0.1f));

                continueButton.OnClick(Continue);

                c.Append(continueButton);
            }
            else
            {
                if (this.showHint)
                {
                    c = new GUIButton();
                    qFactory.Append(c);
                    c.SetBox((new Box())
                             .SetMarginTop(0.1f)
                             .SetMarginRight(0.1f)
                             .SetMarginBottom(0.1f)
                             .SetMarginLeft(0.1f));

                    GUIButton z = (GUIButton)c;
                    z.SetStyle(GUIStyles.GetInstance().DEFAULT_SLIDE_STYLE);
                    z.SetText(question.GetHint() + "\n\n(Click to hide hint)");
                    z.OnClick(HideHint);
                }
                else
                {
                    c = qFactory
                        .CreateLabel(question.GetText())
                        .SetBox((new Box())
                                .SetMarginTop(0.1f)
                                .SetMarginRight(0.1f)
                                .SetMarginBottom(0.1f)
                                .SetMarginLeft(0.1f));

                    GUILabel l = (GUILabel)c;

                    l.SetStyle(GUIStyles.GetInstance().DEFAULT_SLIDE_STYLE);
                }
                if (currentAnswer != -1)
                {
                    // We have a selected answer, show the "next" button
                    GUIButton submitAnswerButton = new GUIButton();
                    submitAnswerButton.SetText("Submit Answer");
                    submitAnswerButton.SetBox(new Box()
                                              .SetMarginTop("auto")
                                              .SetMarginLeft("auto")
                                              .SetMarginRight(0.01f)
                                              .SetMarginBottom(0.01f)
                                              .SetWidth(Screen.width * 0.2 + "px")
                                              .SetHeight(0.1f));

                    submitAnswerButton.OnClick(SubmitAnswer);

                    c.Append(submitAnswerButton);
                }

                for (int i = 0; i < this.question.GetAnswers().Length; i++)
                {
                    GUIButton button = new GUIButton();

                    button.SetText(this.question.GetAnswers() [i]);
                    button.SetBox(questionBoxes [i]);

                    if (currentAnswer == i)
                    {
                        button.SetPressed(true);
                    }

                    switch (i)
                    {
                    case 0:
                        button.OnClick(QuestionAnswerA);
                        break;

                    case 1:
                        button.OnClick(QuestionAnswerB);
                        break;

                    case 2:
                        button.OnClick(QuestionAnswerC);
                        break;

                    case 3:
                        button.OnClick(QuestionAnswerD);
                        break;

                    default:
                        break;
                    }

                    c.Append(button);
                }

                c.Append(backButton);
            }

            GUIStructure questionGUI = qFactory.Build();
            questionGUI.OnGUI(gameObject);

            break;

        case SlideState.TEXT:
            gui.OnGUI(gameObject);
            break;

        case SlideState.DONE:
            FlowControl.NextSlide();
            break;

        default:
            break;
        }
    }