private void InitializeButtons() { itemButton1 = transform.Find("Item1 Button").gameObject.GetComponent <FocusableButton>(); itemButton2 = transform.Find("Item2 Button").gameObject.GetComponent <FocusableButton>(); itemButton3 = transform.Find("Item3 Button").gameObject.GetComponent <FocusableButton>(); itemButton4 = transform.Find("Item4 Button").gameObject.GetComponent <FocusableButton>(); itemButton5 = transform.Find("Item5 Button").gameObject.GetComponent <FocusableButton>(); buttons.Add(itemButton1); buttons.Add(itemButton2); buttons.Add(itemButton3); buttons.Add(itemButton4); buttons.Add(itemButton5); for (int i = 0; i < buttons.Count; i++) { buttons[i].OnButtonPressed = OnQuizSelected; } pageDownButton = transform.Find("Down Button").gameObject.GetComponent <FocusableButton>(); pageUpButton = transform.Find("Up Button").gameObject.GetComponent <FocusableButton>(); pageDownButton.OnPressed = PageDown; pageUpButton.OnPressed = PageUp; OnUpdateLanguage(); FillQuizzes(); }
private void InitializeButtons() { closeButton = transform.Find("Close Button").GetComponent <FocusableButton>(); deleteButton = transform.Find("Delete Button").GetComponent <FocusableButton>(); editButton = transform.Find("Edit Button").GetComponent <FocusableButton>(); playPauseButton = transform.Find("Play Button").GetComponent <FocusableButton>(); recordAudioButton = transform.Find("Record Button").GetComponent <FocusableButton>(); stopButton = transform.Find("Stop Button").GetComponent <FocusableButton>(); closeButton.OnPressed = Close; deleteButton.OnPressed = DeleteAnnotation; editButton.OnPressed = EditText; playPauseButton.OnPressed = PlayPauseAudio; recordAudioButton.OnPressed = RecordAudio; stopButton.OnPressed = StopAudio; // if the window somehow got instantiated without an attached container: disable the edit and delete button if (Container == null) { editButton.ButtonEnabled = false; deleteButton.ButtonEnabled = false; } // disable the record button if there is no microphone if (recordAudioButton != null && Microphone.devices.Length == 0) { recordAudioButton.ButtonEnabled = false; } }
void Awake() { focusableButtonComponent = GetComponent <FocusableButton>(); if (focusableButtonComponent != null) { focusableButtonComponent.OnPressed = KeyPressed; } buttonConfiguration = GetComponent <ButtonConfiguration>(); keyboard = transform.parent.GetComponent <Keyboard>(); }
private void InitializeButtons() { cancelButton = transform.Find("Cancel Button").gameObject.GetComponent <FocusableButton>(); positionToNameButton = transform.Find("PositionName Button").gameObject.GetComponent <FocusableButton>(); nameToPositionButton = transform.Find("NamePosition Button").gameObject.GetComponent <FocusableButton>(); randomButton = transform.Find("Random Button").gameObject.GetComponent <FocusableButton>(); cancelButton.OnPressed = () => { Close(false); }; positionToNameButton.OnPressed = () => { actions.SelectQuizPositionToName(); Close(true); }; nameToPositionButton.OnPressed = () => { actions.SelectQuizNameToPosition(); Close(true); }; randomButton.OnPressed = () => { actions.SelectQuizRandom(); Close(true); }; OnUpdateLanguage(); }
private void InitializeButtons() { settingsButton = transform.Find("Settings Button").GetComponent <FocusableButton>(); loginButton = transform.Find("Login Button").GetComponent <FocusableButton>(); authorButton = transform.Find("Author Button").GetComponent <FocusableCheckButton>(); settingsButton.OnPressed = ShowSettings; loginButton.OnPressed = Login; authorButton.OnPressed = TogglePlayerType; authorButton.ButtonChecked = (InformationManager.Instance.playerType == PlayerType.AUTHOR); OnUpdateLanguage(); }
private void InitializeButtons() { upButton = transform.Find("Up Button").gameObject.GetComponent <FocusableButton>(); downButton = transform.Find("Down Button").gameObject.GetComponent <FocusableButton>(); closeButton = transform.Find("Close Button").gameObject.GetComponent <FocusableButton>(); upButton.OnPressed = PageUp; downButton.OnPressed = PageDown; closeButton.OnPressed = Close; OnUpdateLanguage(); MenuEnabled = false; }
private void InitializeButtons() { button = transform.Find("Button").gameObject.GetComponent <FocusableButton>(); boundingBoxMenu.OnCloseAction = () => { gameObject.SetActive(true); }; button.OnPressed = () => { boundingBoxMenu.gameObject.SetActive(true); gameObject.SetActive(false); }; }
/// <summary> /// Initializes the buttons; gets all requires references /// </summary> private void InitializeButtons() { // get/create buttons titleField = transform.Find("Title Button").gameObject.GetComponent <FocusableContentButton>(); commentField = transform.Find("Comment Button").gameObject.GetComponent <FocusableContentButton>(); postOnReqBaz = transform.Find("Post ReqBaz Button").gameObject.GetComponent <FocusableButton>(); closeButton = transform.Find("Close Button").gameObject.GetComponent <FocusableButton>(); // set button actions postOnReqBaz.OnPressed = SubmitToReqBaz; titleField.OnPressed = () => { Keyboard.Display(LocalizationManager.Instance.ResolveString("Enter the feedback title"), title, 50, TitleSet, true); }; commentField.OnPressed = () => { Keyboard.Display(LocalizationManager.Instance.ResolveString("Enter your feedback"), comment, CommentSet, true); }; closeButton.OnPressed = Close; OnUpdateLanguage(); }
/// <summary> /// Applies the currently selected button type /// Adapts the visibility of sub-controls and handles the transition between two button types /// </summary> private void UpdateButtonType() { // disable all specific controls and just re-enable the needed control // this simplifies transition between button types DisableAllSpecificControls(); // remove button script to exchange it for a new type // but store the settings of the button StoreButtonSettings(); DestroyImmediate(currentButtonComponent); switch (type) { case ButtonType.BUTTON: currentButtonComponent = gameObject.AddComponent <FocusableButton>(); break; case ButtonType.CHECK_BUTTON: if (ledTransform != null) { ledTransform.gameObject.SetActive(true); currentButtonComponent = gameObject.AddComponent <FocusableCheckButton>(); } else { Debug.LogError("Tried to set focusable check button without LED. This is not allowed (" + gameObject.name + ")"); } break; case ButtonType.CONTENT_BUTTON: if (contentTransform != null) { contentTransform.gameObject.SetActive(true); currentButtonComponent = gameObject.AddComponent <FocusableContentButton>(); } else { Debug.LogError("Tried to set focusable content button without content label. This is not allowed (" + gameObject.name + ")"); } break; } RestoreButtonSettings(); }
/// <summary> /// Initializes the configuration script /// Gets the necessary transforms and components /// </summary> private void Initialize() { Transform spriteTransform = transform.Find("Icon"); captionTransform = transform.Find("Caption"); ledTransform = transform.Find("LED"); contentTransform = transform.Find("Content"); if (spriteTransform != null) { spriteRenderer = spriteTransform.GetComponent <SpriteRenderer>(); if (spriteRenderer != null) { icon = spriteRenderer.sprite; } } currentButtonComponent = gameObject.GetComponent <FocusableButton>(); UpdateButtonType(); }
private void InitializeButtons() { deleteButton = transform.Find("Delete Button").gameObject.GetComponent <FocusableButton>(); editModeButton = transform.Find("EditMode Button").gameObject.GetComponent <FocusableCheckButton>(); boundingBoxButton = transform.Find("Box Button").gameObject.GetComponent <FocusableCheckButton>(); quizButton = transform.Find("Quiz Button").gameObject.GetComponent <FocusableCheckButton>(); createQuizButton = transform.Find("CreateQuiz Button").gameObject.GetComponent <FocusableButton>(); closeButton = transform.Find("Close Button").gameObject.GetComponent <FocusableButton>(); deleteButton.OnPressed = () => { actions.DeleteObject(); Destroy(); }; editModeButton.OnPressed = ToggleEditMode; boundingBoxButton.OnPressed = ToggleBoundingBox; quizButton.OnPressed = SelectQuiz; closeButton.OnPressed = Close; createQuizButton.OnPressed = actions.CreateNewQuiz; boundingBoxButton.ButtonChecked = true; editModeButton.ButtonChecked = true; quizButton.ButtonChecked = false; OnUpdateLanguage(); }
private void InitializeButtons() { upButton = transform.Find("Up Button").gameObject.GetComponent <FocusableButton>(); downButton = transform.Find("Down Button").gameObject.GetComponent <FocusableButton>(); settingsButton = transform.Find("Settings Button").gameObject.GetComponent <FocusableButton>(); logoutButton = transform.Find("Logout Button").gameObject.GetComponent <FocusableButton>(); badgeButton = transform.Find("Badges Button").gameObject.GetComponent <FocusableButton>(); feedbackButton = transform.Find("Feedback Button").gameObject.GetComponent <FocusableButton>(); upButton.OnPressed = PageUp; downButton.OnPressed = PageDown; settingsButton.OnPressed = ShowSettings; badgeButton.OnPressed = ShowBadgeOverview; feedbackButton.OnPressed = ShowFeedbackForm; logoutButton.OnPressed = Logout; OnUpdateLanguage(); // determine badge button visibility and fill the gap bool showBadgeButton = InformationManager.Instance.playerType != PlayerType.AUTHOR; badgeButton.gameObject.SetActive(showBadgeButton); GameObject topMenu2Shorter = transform.Find("Top Menu Medium").gameObject; topMenu2Shorter.SetActive(!showBadgeButton); GameObject topMenu1Shorter = transform.Find("Top Menu Short").gameObject; topMenu1Shorter.SetActive(showBadgeButton); if (!showBadgeButton) // shift the next button to fill the gap { feedbackButton.transform.localPosition = badgeButton.transform.localPosition; } MenuEnabled = false; }
private void InitializeButtons() { // get/create buttons closeButton = transform.Find("Close Button").gameObject.GetComponent <FocusableButton>(); languageButton = transform.Find("Language Button").gameObject.GetComponent <FocusableContentButton>(); modelServerButton = transform.Find("Model Server Button").gameObject.GetComponent <FocusableContentButton>(); gamificationServerButton = transform.Find("Gamification Server Button").gameObject.GetComponent <FocusableContentButton>(); sharingServerButton = transform.Find("Sharing Server Button").gameObject.GetComponent <FocusableContentButton>(); sharingEnabledButton = transform.Find("Sharing Enabled Button").gameObject.GetComponent <FocusableContentButton>(); collisionButton = transform.Find("Collision Detection Button").gameObject.GetComponent <FocusableContentButton>(); versionLabel = transform.Find("Version Label").gameObject.GetComponent <TextMesh>(); SettingsActions actions = gameObject.AddComponent <SettingsActions>(); // set button actions closeButton.OnPressed = Close; languageButton.OnPressed = ChangeLanguage; modelServerButton.OnPressed = actions.EnterServer; gamificationServerButton.OnPressed = actions.EnterGamificationServer; sharingServerButton.OnPressed = actions.EnterSharingServer; sharingEnabledButton.OnPressed = () => { actions.ToggleSharing(); SetButtonContents(); }; collisionButton.OnPressed = () => { actions.ToggleCollision(); SetButtonContents(); }; OnUpdateLanguage(); // set contents SetButtonContents(); }