/// <summary> /// Check if camera is pointing at any key. /// If it does changes state of key /// </summary> private void RayCastKeyboard() { ray = new Ray(raycastingSource.position, raycastingSource.forward); if (Physics.Raycast(ray, out hit, rayLength, layer)) // If any key was hit { KeyboardItem focusedKeyItem = hit.transform.gameObject.GetComponent <KeyboardItem>(); if (focusedKeyItem != null) // Hit may occur on item without script { ChangeCurrentKeyItem(focusedKeyItem); keyItemCurrent.Hovering(); #if !UNITY_HAS_GOOGLEVR if (Input.GetButtonDown(clickInputName)) // If key clicked { #else if (Input.GetMouseButtonDown(0)) { #endif keyItemCurrent.Click(); keyboardStatus.HandleClick(keyItemCurrent); } } } else if (keyItemCurrent != null) // If no target hit and lost focus on item { ChangeCurrentKeyItem(null); } }
/// <summary> /// Handles click on keyboarditem /// </summary> /// <param name="clicked">keyboard item clicked</param> public void HandleClick(KeyboardItem clicked) { string value = clicked.GetValue(); if (value.Equals(QEH) || value.Equals(ABC)) // special signs pressed { ChangeSpecialLetters(); } else if (value.Equals(UP) || value.Equals(LOW)) // upper/lower case pressed { LowerUpperKeys(); } else if (value.Equals(SPACE)) { TypeKey(BLANKSPACE); } else if (value.Equals(BACK)) { BackspaceKey(); } else // Normal letter { TypeKey(value[0]); } }
public void checkErrors() { errorReporter = ErrorReporter.Instance; errorReporter.Reset(); /* * if(keys.Length != KEY_NUMBER) {//is there correct number of keys * errorReporter.SetMessage("Cannot procced. Number of keys is incorrect. Revert your changes to prefab", ErrorReporter.Status.Error); * return; * } */ if (space == null) // project improted over older package crashes without this { space = keys[spaceKeyNumber]; } if (space.GetMeshName().Equals(MESH_NAME_SEARCHED)) //are keys positioned corectly { errorReporter.SetMessage("Cannot procced. Space key data is incorrect. Revert your changes to prefab or place keys in correct sequence", ErrorReporter.Status.Error); return; } if (!gameObject.GetComponent <KeyboardStatus>().isReflectionPossible) { errorReporter.SetMessage("GameObject Output is not set, or there is no script with \"text\" property on current gameobject", ErrorReporter.Status.Warning); return; } if (wasStaticOnStart && Application.isPlaying) //is playing and was static when play mode started { errorReporter.SetMessage("If editng during gameplay is necessary, quit gameplay and remove static flag from keyboard and its children." + " Reamember to set keyboard to static when building", ErrorReporter.Status.Info); return; } CheckKeyArrays(); }
/// <summary> /// Handles click on keyboarditem /// </summary> /// <param name="clicked">keyboard item clicked</param> public void HandleClick(KeyboardItem clicked) { string value = clicked.GetValue(); if (value.Equals(OK) && output.text.Length > 2) { ApplicationManager.nome = output.text; GameObject.Find("0.Keyboard").SetActive(false); Menu.SetActive(true); return; } else if (value.Equals(QEH) || value.Equals(ABC)) // special signs pressed { ChangeSpecialLetters(); } else if (value.Equals(UP) || value.Equals(LOW)) // upper/lower case pressed { LowerUpperKeys(); } else if (value.Equals(SPACE)) { TypeKey(BLANKSPACE); } else if (value.Equals(BACK)) { BackspaceKey(); } else if (!value.Equals(OK)) // Normal letter { TypeKey(value[0]); } }
private Vector3 RestorePosition(KeyboardItem key) { return(new Vector3( key.transform.localPosition.x, key.transform.localPosition.y, key.transform.localPosition.z - centerPointDistance + radius)); }
private void ChangeCurrentKeyItem(KeyboardItem key) { if (keyItemCurrent != null) { keyItemCurrent.StopHovering(); } keyItemCurrent = key; }
/// <summary> /// Calculates whole transformation for single key /// </summary> /// <param name="iteration">index of key to be placed</param> /// <param name="keyTransform">key transformation</param> private void PositionSingleLetter(KeyboardItem key) { int iteration = key.Position; Transform keyTransform = key.transform; // Check row and how many keys were palced float keysPlaced = CalculateKeyOffsetAndRow(iteration); Vector3 positionOnCylinder = CalculatePositionOnCylinder(lettersInRowsCount[row] - 1, iteration - keysPlaced); positionOnCylinder = AdditionalTransformations(keyTransform, positionOnCylinder); LookAtTransformation(keyTransform, positionOnCylinder.y); RotationTransformation(keyTransform); }
public void InitKeys() { if (keys == null || KeyboardItem.forceInit) { List <KeyboardItem> allKeys = new List <KeyboardItem>(GetComponentsInChildren <KeyboardItem>()); for (int i = 0; i < allKeys.Count; i++) { allKeys[i].Position = i; allKeys[i].Init(); } space = allKeys[spaceKeyNumber]; keys = allKeys.ToArray(); } space.ManipulateSpace(this, SpaceSprite); }
/// <summary> /// Calculates whole transformation for single key /// Whole idea is to create circle and place keys on it /// if keys are in straight line, it means that deegre /// between step is really low. /// </summary> /// <param name="iteration">index of key to be placed</param> /// <param name="keyTransform">key transformation</param> private void PositionSingleLetter(KeyboardItem key) { int iteration = key.Position; Transform keyTransform = key.transform; // Check row and how many keys were placed float keysPlaced = CalculateKeyOffsetAndRow(iteration); float degree = CalculateRotation(lettersInRowsCount[row] - 1, iteration - keysPlaced); //caluclate position on cylinder with circle equation formula //http://www.mathopenref.com/coordparamcircle.html key.transform.localPosition = CalculatePositionOnCylinder(degree); //rotate keys by their placement angle key.transform.localEulerAngles = new Vector3(0, -degree * Mathf.Rad2Deg - 90f, 0); // keys are moved from center couse of increasing circle radius, // so position must be restored to radius key.transform.localPosition = RestorePosition(key); }
/// <summary> /// Check if camera is pointing at any key. /// If it does changes state of key /// </summary> private void RayCastKeyboard() { ray = new Ray(raycastingSource.position, raycastingSource.forward); if (Physics.Raycast(ray, out hit, rayLength, layer)) // If any key was hit { KeyboardItem focusedKeyItem = hit.transform.gameObject.GetComponent <KeyboardItem>(); if (focusedKeyItem != null) // Hit may occur on item without script { ChangeCurrentKeyItem(focusedKeyItem); keyItemCurrent.Hovering(); if (focusedKeyItem.letter.text == "a") { if (sceneName != "SceneA") { SceneManager.LoadScene("SceneA"); } } if (focusedKeyItem.letter.text == "b") { if (sceneName != "SceneC") { SceneManager.LoadScene("SceneC"); } } if (focusedKeyItem.letter.text == "c") { if (sceneName != "SceneD") { SceneManager.LoadScene("SceneD"); } } } } else if (keyItemCurrent != null) // If no target hit and lost focus on item { ChangeCurrentKeyItem(null); } }
/// <summary> /// Handles click on keyboarditem /// </summary> /// <param name="clicked">keyboard item clicked</param> public void HandleClick(KeyboardItem clicked) { string value = clicked.GetValue(); if (value.Equals(QEH) || value.Equals(ABC)) { // special signs pressed ChangeSpecialLetters(); } else if (value.Equals(UP) || value.Equals(LOW)) { // upper/lower case pressed LowerUpperKeys(); } else if (value.Equals(SPACE)) { // TypeKey(Enter); /* ==>> This is where the events occured after hit enter button. * 1. Receieve the value of text. * 2. Make the event occures. * 2.1 User should be leaded to another scene. * 2.2 Or to the spacific coordinate. */ Debug.Log(string.Format("Debug : Inside handleClick(KeyboardStatus) Output: " + GetOutput())); sentOutput = GetOutput(); // if (GetOutput() == "2itz" || GetOutput() == "1tup" || GetOutput() == "1atn") // { Debug.Log(string.Format("Debug : Inside if condition(KeyboardStatus)")); //SceneManager.LoadScene("ProteinMoleculeScene"); //SceneManager.LoadScene("Test"); //SceneManager.LoadScene("NewRaycast"); SceneManager.LoadScene("ChainChoosingScene"); // } } else if (value.Equals(BACK)) { BackspaceKey(); } else { TypeKey(value[0]); } }
/// <summary> /// Check if camera is pointing at any key. /// If it does changes state of key /// </summary> private void RayCastKeyboard() { ray = new Ray(raycastingSource.position, raycastingSource.forward); if (Physics.Raycast(ray, out hit, rayLength, layer)) // If any key was hit { KeyboardItem focusedKeyItem = hit.transform.gameObject.GetComponent <KeyboardItem>(); if (focusedKeyItem != null) // Hit may occur on item without script { ChangeCurrentKeyItem(focusedKeyItem); keyItemCurrent.Hovering(); if (buttons != null) { if (!tp) { if (buttons.triggerPressed) {// If key clicked tp = true; keyItemCurrent.Click(); keyboardStatus.HandleClick(keyItemCurrent); } } else { if (!buttons.triggerPressed) { tp = false; } } } else { keyItemCurrent.Click(); keyboardStatus.HandleClick(keyItemCurrent); } } } else if (keyItemCurrent != null) // If no target hit and lost focus on item { ChangeCurrentKeyItem(null); } }
/// <summary> /// Check if camera is pointing at any key. /// If it does changes state of key /// </summary> private void RayCastKeyboard() { ray = new Ray(raycastingSource.position, raycastingSource.forward); if (Physics.Raycast(ray, out hit, rayLength, layer)) // If any key was hit { KeyboardItem focusedKeyItem = hit.transform.gameObject.GetComponent <KeyboardItem>(); if (focusedKeyItem != null) // Hit may occur on item without script { ChangeCurrentKeyItem(focusedKeyItem); keyItemCurrent.Hovering(); #if !UNITY_HAS_GOOGLEVR //former: if(Input.GetButtonDown(clickInputName)) if (controller.GetComponent <VRTK.VRTK_InteractGrab>().IsGrabButtonPressed()) { // If key clicked #else if (GvrController.TouchDown) { #endif //If the user has clicked, //debounce is false, it is not a duplicate click as a result of the update cycle if (debounce == false) { keyItemCurrent.Click(); keyboardStatus.HandleClick(keyItemCurrent); } debounce = true; //set true, because this click has already been used. } else { debounce = false; //user ended previous click } } } else if (keyItemCurrent != null) // If no target hit and lost focus on item { ChangeCurrentKeyItem(null); } }