-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example scene using the UI Input Module
- Loading branch information
Showing
8 changed files
with
10,275 additions
and
14 deletions.
There are no files selected for viewing
1,195 changes: 1,189 additions & 6 deletions
1,195
XR_Keyboard/Assets/XR_Keyboard/Prefabs/QwertyKeyboard-Styled.prefab
Large diffs are not rendered by default.
Oops, something went wrong.
8,971 changes: 8,971 additions & 0 deletions
8,971
XR_Keyboard/Assets/XR_Keyboard/Scenes/ExampleKeyboardScene - UI Input Module.unity
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
XR_Keyboard/Assets/XR_Keyboard/Scenes/ExampleKeyboardScene - UI Input Module.unity.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
XR_Keyboard/Assets/XR_Keyboard/Scripts/Keyboard_Management/RelativeToHeadKeyboardSpawner.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using Leap.Unity.Controllers; | ||
using Leap.Unity.Interaction.Keyboard; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.UIElements; | ||
|
||
namespace Leap.Unity.Interaction.Storage | ||
{ | ||
public class RelativeToHeadKeyboardSpawner : KeyboardSpawner | ||
{ | ||
public Transform head; | ||
public Vector3 DistanceFromHead = new Vector3(0, -0.5f, 0.4f); | ||
public Vector3 Angles; | ||
|
||
private Vector3 targetLocation; | ||
private Quaternion targetRotation; | ||
|
||
private Coroutine moveToRoutine; | ||
|
||
public override void SpawnKeyboard() | ||
{ | ||
if (keyboardActive) | ||
{ | ||
return; | ||
} | ||
else | ||
{ | ||
keyboardActive = true; | ||
} | ||
KeyboardPrefabRoot.SetActive(keyboardActive); | ||
|
||
} | ||
|
||
public override void SpawnKeyboard(Transform currentlySelected) | ||
{ | ||
SpawnKeyboard(); | ||
} | ||
|
||
private void SetPosition() | ||
{ | ||
|
||
Vector3 newPosition = head.position + (head.forward * DistanceFromHead.z); | ||
newPosition.y = head.position.y + DistanceFromHead.y; | ||
|
||
targetLocation = newPosition; | ||
|
||
if (moveToRoutine != null) | ||
{ | ||
StopCoroutine(moveToRoutine); | ||
} | ||
moveToRoutine = StartCoroutine("MoveToTarget"); | ||
} | ||
|
||
private IEnumerator MoveToTarget() | ||
{ | ||
while (Vector3.Distance(KeyboardPrefabRoot.transform.position, targetLocation) > 0.005f) | ||
{ | ||
KeyboardPrefabRoot.transform.position = Vector3.Lerp(KeyboardPrefabRoot.transform.position, targetLocation, Time.deltaTime * 30); | ||
KeyboardPrefabRoot.transform.rotation = Quaternion.Lerp(KeyboardPrefabRoot.transform.rotation, targetRotation, Time.deltaTime * 30); | ||
|
||
Vector3 pos = KeyboardPrefabRoot.transform.position; | ||
pos.y = head.position.y; | ||
Vector3 forward = pos - head.position; | ||
targetRotation = Quaternion.LookRotation(forward, Vector3.up); | ||
|
||
yield return new WaitForEndOfFrame(); | ||
} | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...oard/Assets/XR_Keyboard/Scripts/Keyboard_Management/RelativeToHeadKeyboardSpawner.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.