private void AddCollection() { SimpleMenuCollection menu = (SimpleMenuCollection)target; ObjectCollection collection = menu.GetComponentInChildren <ObjectCollection>(); if (collection == null) { collection = menu.gameObject.AddComponent <ObjectCollection>(); } menu.ParentCollection = collection; }
protected IEnumerator ShowGameplayFeedback() { string userName = "******"; string result = string.Empty; if (!LanderGameplay.Instance.HasCrashed) { // Landed successfully result = string.Format(SuccessPhrases[Random.Range(0, SuccessPhrases.Length)], userName); } else { // Failed result = string.Format(FailurePhrases[Random.Range(0, FailurePhrases.Length)], userName); } SimpleMenuCollection menu = this.gameplayFinishedMenu.GetComponent <SimpleMenuCollection>(); menu.Title = SimpleDialogShell.WordWrap(result, MaxCharsPerLine); menu.Subtitle = "Your score: " + LanderGameplay.Instance.Score.ToString(); // Set this true regardless highScoreDisplayParent.SetActive(true); // TEMP disable high score //highScoreDisplay.SetActive(true); // If we got a high score, show the leaderboard and wait for input // TEMP disable high score /*if (HighScoreManager.Instance.IsHighScore (LanderGameplay.Instance.Score)) { * highScoreInputField.gameObject.SetActive(true); * directionIndicator.TargetObject = highScoreInputField.gameObject; * // Set the text to the last high score input * Keyboard.Instance.m_InputField.text = highScoreText; * Keyboard.Instance.onTextUpdated += OnTextUpdated; * // TODO set focuser based on control scheme * Keyboard.Instance.PresentKeyboard(HUX.Focus.FocusManager.Instance.GazeFocuser); * }*/ // Show the try again menu gameplayFinishedMenu.SetActive(true); directionIndicator.TargetObject = gameplayFinishedMenu.gameObject; yield break; }
public override void OnInspectorGUI() { SimpleMenuCollection menu = (SimpleMenuCollection)target; HUXEditorUtils.BeginSectionBox("Menu settings"); menu.DisplayTitle = EditorGUILayout.Toggle("Display Title", menu.DisplayTitle); if (menu.DisplayTitle) { //menu.TitleText.font = (Font)EditorGUILayout.ObjectField("Title font", menu.TitleText.font, typeof(Font), false); menu.Title = EditorGUILayout.TextArea(menu.Title); menu.TitleText = HUXEditorUtils.DropDownComponentField <TextMesh>("Title TextMesh", menu.TitleText, menu.transform); } menu.DisplaySubtitle = EditorGUILayout.Toggle("Display Subtitle", menu.DisplaySubtitle); if (menu.DisplaySubtitle) { //menu.TitleText.font = (Font)EditorGUILayout.ObjectField("Title font", menu.TitleText.font, typeof(Font), false); menu.Subtitle = EditorGUILayout.TextArea(menu.Subtitle); menu.SubtitleText = HUXEditorUtils.DropDownComponentField <TextMesh>("Subtitle TextMesh", menu.SubtitleText, menu.transform); } menu.ButtonPrefab = (GameObject)EditorGUILayout.ObjectField("Button prefab", menu.ButtonPrefab, typeof(GameObject), false); menu.ParentCollection = HUXEditorUtils.DropDownComponentField <ObjectCollection>("Collection parent", menu.ParentCollection, menu.transform); if (menu.ButtonPrefab == null) { HUXEditorUtils.ErrorMessage("You must specify a button prefab"); HUXEditorUtils.EndSectionBox(); return; } if (menu.ParentCollection == null) { HUXEditorUtils.ErrorMessage("This menu needs a collection component to work", AddCollection, "Fix"); HUXEditorUtils.EndSectionBox(); return; } bool showIcon = false; bool showText = false; CompoundButtonIcon icon = menu.ButtonPrefab.GetComponent <CompoundButtonIcon>(); showIcon = icon != null; CompoundButtonText text = menu.ButtonPrefab.GetComponent <CompoundButtonText>(); showText = text != null; ButtonIconProfile profile = null; if (icon != null) { profile = icon.IconProfile; } HUXEditorUtils.BeginSubSectionBox("Buttons"); HUXEditorUtils.DrawSubtleMiniLabel("Up to " + SimpleMenuCollection.MaxButtons + " allowed. Un-named buttons will be ignored."); SimpleMenuCollectionButton[] buttons = menu.Buttons; HashSet <string> buttonNamesSoFar = new HashSet <string>(); int numButtons = 0; for (int i = 0; i < buttons.Length; i++) { if (!buttons[i].IsEmpty) { numButtons++; } DrawButtonEditor(buttons[i], showIcon, showText, profile, "buttons", i, buttonNamesSoFar); } HUXEditorUtils.EndSubSectionBox(); menu.EditorRefreshButtons(); HUXEditorUtils.BeginSubSectionBox("Menu preview"); HUXEditorUtils.DrawSubtleMiniLabel("An approximation of what the menu will look like."); List <SimpleMenuCollectionButton> buttonsList = new List <SimpleMenuCollectionButton>(buttons); buttonsList.Sort(delegate(SimpleMenuCollectionButton b1, SimpleMenuCollectionButton b2) { return(b1.Index.CompareTo(b2.Index)); }); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, false, false, GUILayout.MinHeight(previewButtonSizeY * numButtons + 50f)); EditorGUILayout.BeginVertical(); bool drewOneButton = false; foreach (SimpleMenuCollectionButton button in buttonsList) { drewOneButton |= DrawPreviewButton(button, showText); } if (!drewOneButton) { HUXEditorUtils.WarningMessage("This state has no buttons due to the options you've chosen. It won't be permitted during play mode."); } EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); HUXEditorUtils.EndSubSectionBox(); HUXEditorUtils.EndSectionBox(); HUXEditorUtils.SaveChanges(menu); }