Skip to content

Instantly share code, notes, and snippets.

@lazarofl
Created May 29, 2018 17:34
Show Gist options
  • Save lazarofl/5a32360a86e1bf0c1d8778305be4681e to your computer and use it in GitHub Desktop.
Save lazarofl/5a32360a86e1bf0c1d8778305be4681e to your computer and use it in GitHub Desktop.
Exemplo de uso das interfaces disponíveis no HoloToolkit
public class CubeManager : MonoBehaviour, IInputClickHandler, INavigationHandler, ISpeechHandler
{
public float RotationSensitivity = 10;
public bool IsRotating = false;
public void OnInputClicked(InputClickedEventData eventData)
{
gameObject.GetComponent<Renderer>().material.color = Color.red;
}
public void OnNavigationCanceled(NavigationEventData eventData)
{
InputManager.Instance.PopModalInputHandler();
}
public void OnNavigationCompleted(NavigationEventData eventData)
{
InputManager.Instance.PopModalInputHandler();
}
public void OnNavigationStarted(NavigationEventData eventData)
{
InputManager.Instance.PushModalInputHandler(gameObject);
}
public void OnNavigationUpdated(NavigationEventData eventData)
{
float rotationFactor_Y = eventData.NormalizedOffset.x * RotationSensitivity;
float rotationFactor_X = eventData.NormalizedOffset.y * RotationSensitivity;
transform.Rotate(new Vector3(rotationFactor_X, -1 * rotationFactor_Y, 0));
}
void ISpeechHandler.OnSpeechKeywordRecognized(SpeechEventData eventData)
{
if (eventData.RecognizedText.ToLower().Equals("start rotation"))
{
IsRotating = true;
}
if (eventData.RecognizedText.ToLower().Equals("stop rotation"))
{
IsRotating = false;
}
eventData.Use();
}
void Update()
{
if(IsRotating)
{
gameObject.transform.Rotate(1, 1, 1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment