/// <summary> /// Initializes the MessageBox: gets all necessary components /// and creates the icon which corresponds to the type of the MessageBox /// </summary> void Start() { btn = button.GetComponent <GaMRButton>(); tagalongScript = GetComponent <SimpleTagalong>(); btn.OnPressed = Accept; if (type == MessageBoxType.ERROR) { Instantiate(Resources.Load("Animated Error"), iconPosition.position, Quaternion.identity, iconPosition); } else if (type == MessageBoxType.SUCCESS) { Instantiate(Resources.Load("Animated Success"), iconPosition.position, Quaternion.identity, iconPosition); } else if (type == MessageBoxType.WARNING) { Instantiate(Resources.Load("Animated Warning"), iconPosition.position, Quaternion.identity, iconPosition); } else if (type == MessageBoxType.INFORMATION) { Instantiate(Resources.Load("Animated Info"), iconPosition.position, Quaternion.identity, iconPosition); } tagalongScript.TagalongDistance = 1.7f + 0.1f * count; }
/// <summary> /// Internal function which is the base for the different public Show methods /// Displays a MessageBox and sets it either at a fixed position or to follow the user /// </summary> /// <param name="text">The text message which should be displayed to the user</param> /// <param name="type">The type of the MessageBox</param> /// <param name="fixedPosition">True if the MessageBox should be displayed at a fixed position</param> /// <param name="position">The global position where the message box is shown (only used if fixedPosition true)</param> /// <param name="rotation">The global rotation of the message box (only used if fixedPosition true)</param> private static void Show(string text, MessageBoxType type, bool fixedPosition, Vector3 position, Quaternion rotation) { // load the MessageBox from the resources and set the necessary variables GameObject messageBox = (GameObject)Instantiate(Resources.Load("MessageBox")); //messageBox.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 3; MessageBox msgBox = messageBox.GetComponent <MessageBox>(); msgBox.Text = text; msgBox.type = type; if (fixedPosition) { // if a fixed position is used: destroy all compononents from the prefab which modify the position and rotation SimpleTagalong tagalong = messageBox.GetComponent <SimpleTagalong>(); Destroy(tagalong); FaceCamera faceCamera = messageBox.GetComponent <FaceCamera>(); Destroy(faceCamera); Window3D window = messageBox.GetComponent <Window3D>(); Destroy(window); // then set the position and rotation messageBox.transform.position = position; messageBox.transform.rotation = rotation; } count++; }
/// <summary> /// this is called when the component is created => register it in the window manager /// </summary> public void Start() { externalWindowLogic = GetComponent <IWindow>(); tagalong = GetComponent <SimpleTagalong>(); faceCamera = GetComponent <FaceCamera>(); WindowManager.Instance.Add(this); renderers = GetComponentsInChildren <Renderer>(); started = true; }
private void Start() { WidthButton.onClick.AddListener(editWidth); HeightButton.onClick.AddListener(editHeight); NameButton.onClick.AddListener(editName); JointSizeButton.onClick.AddListener(editJointSize); ThicknessButton.onClick.AddListener(editThickness); TextureButton.onClick.AddListener(editTexture); EditButton.onClick.AddListener(enableEditing); // canceling the edit mode restores the values of the current tile CancelEditButton.onClick.AddListener(disableEditing); CancelEditButton.onClick.AddListener(() => TileMenuManager.Instance.ShowDetailView(CurrentTile)); // accepting the edit mode saves the values to the current tile AcceptEditButton.onClick.AddListener(disableEditing); AcceptEditButton.onClick.AddListener(saveTile); PlaceTileButton.onClick.AddListener(placeTiles); m_CanvasGroup = GetComponent <CanvasGroup>(); m_TagAlong = GetComponent <SimpleTagalong>(); }
private static void Display(string label, string text, int maxNumberOfCharacters, Action <string> callWithResult, bool fullKeyboard, bool fixedPosition, Vector3 position, Quaternion rotation) { GameObject keyboardInstance; if (fullKeyboard) { keyboardInstance = GameObject.Instantiate(WindowResources.Instance.Keyboard); } else { keyboardInstance = GameObject.Instantiate(WindowResources.Instance.Numpad); } Keyboard keyboard = keyboardInstance.GetComponent <Keyboard>(); keyboard.label.text = label; keyboard.Text = text; keyboard.callWithResult = callWithResult; keyboard.IsFullKeyboard = fullKeyboard; keyboard.MaxLength = maxNumberOfCharacters; if (fixedPosition) // use a fixed position for the keyboardi instead of tracking it with the view { // delete the components from the prefab which realize the view tracking SimpleTagalong tagalong = keyboardInstance.GetComponent <SimpleTagalong>(); Destroy(tagalong); FaceCamera faceCamera = keyboardInstance.GetComponent <FaceCamera>(); Destroy(faceCamera); Window3D window = keyboardInstance.GetComponent <Window3D>(); Destroy(window); // set the position of the keyboard keyboardInstance.transform.position = position; keyboardInstance.transform.rotation = rotation; } currentlyOpenedKeyboard = keyboard; }