Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Created January 29, 2017 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flushpot1125/8745b2f3e202d7082a29462b5d4b941c to your computer and use it in GitHub Desktop.
Save flushpot1125/8745b2f3e202d7082a29462b5d4b941c to your computer and use it in GitHub Desktop.
/*copied from "https://developer.microsoft.com/en-us/windows/holographic/holograms_101"*/
using UnityEngine;
public class SphereCommands : MonoBehaviour {
Vector3 originalPosition;
void Start() {
// Grab the original local position of the sphere when the app starts.
originalPosition = this.transform.localPosition;
}
// Called by GazeGestureManager when the user performs a Select gesture
void OnSelect() {
// If the sphere has no Rigidbody component, add one to enable physics.
if (!this.GetComponent<Rigidbody>()) {
var rigidbody = this.gameObject.AddComponent<Rigidbody>();
rigidbody.collisionDetectionMode = CollisionDetectionMode.Continuous;
}
}
// Called by SpeechManager when the user says the "Reset world" command
void OnReset() {
// If the sphere has a Rigidbody component, remove it to disable physics.
var rigidbody = this.GetComponent<Rigidbody>();
if (rigidbody != null) {
DestroyImmediate(rigidbody);
}
// Put the sphere back into its original local position.
this.transform.localPosition = originalPosition;
}
// Called by SpeechManager when the user says the "Drop sphere" command
void OnDrop() {
// Just do the same logic as a Select gesture.
OnSelect();
}
/*added by @WheetTweet*/
void OnExpand() {
this.transform.localScale = new Vector3(2, 2, 2);
}
/*added by @WheetTweet*/
void OnRotate() {
this.transform.Rotate(0,0,30);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment