public override void OnGUI(GameObject gameObject) { this.CalculateField(); this.CalculateInsideField(); Rect outsideField = new Rect(this.field); outsideField.x -= 5; outsideField.y -= 5; outsideField.width += 5 * 2; outsideField.height += 5 * 2; GUI.Label(outsideField, new GUIContent(""), GUIStyles.GetInstance().DEFAULT_WHITE_STYLE); // SCROLL BAR scrollPosition = GUI.BeginScrollView(field, scrollPosition, insideField, false, true); // Fake the child's percieved parent's size: Rect tempField = this.field; this.field = insideField; // Children will be called! base.OnGUI(gameObject); // End the scroll view that we began above. GUI.EndScrollView(); this.field = tempField; }
public FishExperience(FishExperience e) : base(e.GetBehavior(), e.GetOwner()) { this.SetTarget(e.GetTarget()); this.SetGameObjects(e.GetGameObjects()); this.SetTotalNumberOfFish(e.GetGameObjects().Count); s = new GUIStyle(GUIStyles.GetInstance().DEFAULT_SLIDE_STYLE); s.fontSize = (int)(s.fontSize * 0.75); }
public override void OnGUI(GameObject gameObject) { // No need to call base // base.OnGUI (gameObject); Rect parentField = GetParentField(); float margin = parentField.width * 0.05f; for (int i = 0; i < lessons.Count; i++) { Rect cR = new Rect(margin, i * (this.buttonHeight + GUILessonList.bufferSize), parentField.width - 2 * margin, this.buttonHeight); Rect imageRect = new Rect( parentField.width - 2 * margin, i * (this.buttonHeight + GUILessonList.bufferSize) + this.buttonHeight * 0.25f, this.buttonHeight * 0.5f, this.buttonHeight * 0.5f); Texture tImage = GUIStyles.GetInstance().COMPLETED_SWATCH; Lesson lesson = lessons[i]; switch (lesson.GetCompletedness()) { case Lesson.COMPLETEDNESS.COMPLETE: tImage = GUIStyles.GetInstance().COMPLETED_SWATCH; break; case Lesson.COMPLETEDNESS.IN_PROGRESS: tImage = GUIStyles.GetInstance().IN_PROGRESS; break; default: tImage = GUIStyles.GetInstance().NOT_COMPLETED; break; } if (GUI.Button(cR, lesson.GetLessonName(), this.guiStyle)) { SoundUtil.getInstance().buttonPlay(gameObject); FlowControl.SetLesson(lesson.GetSceneName()); Application.LoadLevel("Lesson_Loader"); } // TODO show whether completed or not GUI.Label(imageRect, tImage); } }
public GUILessonList(List <Lesson> lessons) { this.lessons = lessons; this.guiStyle = GUIStyles.GetInstance().DEFAULT_LESSON_BUTTON_STYLE; }
/** * Initialization code. * * Set up distances and origin points. */ void Start() { controller = GetComponent <CharacterController>(); // Adjust the collider size to fit a fish controller.height = colliderHeight; controller.radius = colliderRadius; model = this.GetComponent <ARModel>(); cam = Camera.main; float componentMaxDistance = maxDistance / 2; float x = Random.Range(-componentMaxDistance, componentMaxDistance); float y = Random.Range(0, componentMaxDistance * 2); float z = Random.Range(-componentMaxDistance, componentMaxDistance); Vector3 startPoint = origin + new Vector3(x, y, z); transform.Translate(startPoint); centerPoint = origin; affected = gameObject.name.Contains("affected"); // ------------------------ Set up GUI ----------------------------------- \\ // Create affected button GUIButton isAffected = new GUIButton(); isAffected.SetText("Yes"); isAffected.SetBox(new Box() .SetMarginTop("auto") .SetMarginRight(0.01f) .SetMarginLeft("auto") .SetMarginBottom(0.01f) .SetWidth(Screen.width * 0.2 + "px") .SetHeight(0.4f)); isAffected.OnClick(this.IThinkItsAffected); // Create not affected button GUIButton isNotAffected = new GUIButton(); isNotAffected.SetText("No"); isNotAffected.SetBox(new Box() .SetMarginTop("auto") .SetMarginRight("auto") .SetMarginLeft(0.01f) .SetMarginBottom(0.01f) .SetWidth(Screen.width * 0.2 + "px") .SetHeight(0.4f)); isNotAffected.OnClick(this.IThinkItsNotAffected); GUIFactory factory = new GUIFactory(); factory.CreateLabel("Has this fish been affected by oil?") .SetBox(new Box() .SetMarginBottom(0.1f) .SetMarginTop(0.6f) .SetMarginLeft(0.1f) .SetMarginRight(0.1f)) .Append(isAffected) .Append(isNotAffected); gui = factory.Build(); // -------------------- Look closely GUI Set up ----------------------------------- \\ // Create Confirm button GUIButton confirm = new GUIButton(); confirm.SetText("Okay"); confirm.SetBox(new Box() .SetMarginTop("auto") .SetMarginRight(0.01f) .SetMarginLeft("auto") .SetMarginBottom(0.01f) .SetWidth(Screen.width * 0.2 + "px") .SetHeight(0.4f)); confirm.OnClick(this.Confirm); GUIFactory lookCloselyGUIFactory = new GUIFactory(); GUIComponent gc = lookCloselyGUIFactory.CreateLabel("Look closely! Fish affected by pollution will have splotches of oil across their scales.") .SetBox(new Box() .SetMarginBottom(0.1f) .SetMarginTop(0.6f) .SetMarginLeft(0.1f) .SetMarginRight(0.1f)); GUILabel gl = (GUILabel)gc; GUIStyle gs = GUIStyles.GetInstance().DEFAULT_WHITE_STYLE; gs.wordWrap = true; gl.SetStyle(gs); gc.Append(confirm); lookCloselyGUI = lookCloselyGUIFactory.Build(); // --------------------- alreadyExaminedGUI -------------------------------------- \\ // Create Confirm button GUIButton confirmAlreadyExamined = new GUIButton(); confirmAlreadyExamined.SetText("Okay"); confirmAlreadyExamined.SetBox(new Box() .SetMarginTop("auto") .SetMarginRight(0.01f) .SetMarginLeft("auto") .SetMarginBottom(0.01f) .SetWidth(Screen.width * 0.2 + "px") .SetHeight(0.4f)); confirmAlreadyExamined.OnClick(this.ConfirmAlreadyExamined); GUIFactory alreadyExaminedGUIFactory = new GUIFactory(); alreadyExaminedGUIFactory.CreateLabel("You have already examined this fish.") .SetBox(new Box() .SetMarginBottom(0.1f) .SetMarginTop(0.6f) .SetMarginLeft(0.1f) .SetMarginRight(0.1f)) .Append(confirmAlreadyExamined); alreadyExaminedGUI = alreadyExaminedGUIFactory.Build(); }
public GUILabel() { this.text = ""; this.style = GUIStyles.GetInstance().DEFAULT_WHITE_STYLE; }
public GUILabel(string text) { this.text = text; this.style = GUIStyles.GetInstance().DEFAULT_WHITE_STYLE; }
/** * Constructor */ public GUIButton() { guiStyle = GUIStyles.GetInstance().DEFAULT_BUTTON_STYLE; clickedTexture = GUIStyles.GetInstance().DARK_ORANGE_SWATCH; }
public FishExperience(System.Type behaviour, Slide owner) : base(behaviour, owner) { s = new GUIStyle(GUIStyles.GetInstance().DEFAULT_SLIDE_STYLE); s.fontSize = (int)(s.fontSize * 0.75); }
public Slide(string text) { state = SlideState.TEXT; this.text = text; GUIFactory factory = 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); // Go Forward Button GUIButton nextButton = new GUIButton(); nextButton.SetText("Continue"); nextButton.SetBox(new Box() .SetMarginTop("auto") .SetMarginLeft("auto") .SetMarginRight(0.01f) .SetMarginBottom(0.01f) .SetWidth(Screen.width * 0.2 + "px") .SetHeight(0.1f)); nextButton.OnClick(FlowControl.NextSlide); GUIComponent c = factory .CreateLabel(text) .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); l.Append(nextButton); l.Append(backButton); gui = factory.Build(); questionBoxes = new Box[4]; questionBoxes [0] = new Box(); questionBoxes [0] .SetMarginTop(0.55f) .SetMarginRight(0.51f) .SetMarginBottom("auto") .SetMarginLeft(0.01f) .SetHeight(0.1f); questionBoxes [1] = new Box(); questionBoxes [1] .SetMarginTop(0.55f) .SetMarginRight(0.01f) .SetMarginBottom("auto") .SetMarginLeft(0.51f) .SetHeight(0.1f); questionBoxes [2] = new Box(); questionBoxes [2] .SetMarginTop(0.7f) .SetMarginRight(0.51f) .SetMarginBottom("auto") .SetMarginLeft(0.01f) .SetHeight(0.1f); questionBoxes [3] = new Box(); questionBoxes [3] .SetMarginTop(0.7f) .SetMarginRight(0.01f) .SetMarginBottom("auto") .SetMarginLeft(0.51f) .SetHeight(0.1f); }
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; } }