Last active
August 12, 2017 01:22
-
-
Save TakahiroMiyaura/aede33ac8467fe30d98c28ceec3fd6ca to your computer and use it in GitHub Desktop.
HoloLensで始めるMRDesignLabs - 両手ジェスチャー入力の実装 ref: http://qiita.com/miyaura/items/d44e50f4cb422fdf0500
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
// get Input Source Hands instance. | |
var hands = InputSources.Instance.hands; | |
// try get current hand state og right hand. | |
var handStateR = hands.GetHandState(InputSourceHands.HandednessEnum.Right, 0.15f); |
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
// Copyright(c) 2017 Takahiro Miyaura | |
// Released under the MIT license | |
// http://opensource.org/licenses/mit-license.php | |
using HUX.Utility; | |
using UnityEngine; | |
[RequireComponent(typeof(LocalHandInput))] | |
public class ManupilateCube : MonoBehaviour | |
{ | |
/// <summary> | |
/// Hand Gesture Component. | |
/// </summary> | |
private LocalHandInput input; | |
/// <summary> | |
/// Initial world position of GameObject field. | |
/// </summary> | |
private Vector3 _initializePos; | |
/// <summary> | |
/// material of GameObject field. | |
/// </summary> | |
private Material material; | |
// Use this for initialization | |
void Start () | |
{ | |
input = gameObject.GetComponent<LocalHandInput>(); | |
_initializePos = gameObject.transform.localPosition; | |
material = new Material(Shader.Find("Diffuse")); | |
gameObject.GetComponent<Renderer>().material = material; | |
} | |
// Update is called once per frame | |
void Update () | |
{ | |
//if Hand is lost,this gameobject's color is become Red. | |
material.color = InputSources.Instance.hands.GetHandState(input.Handedness, input.MinConfidence) == null ? Color.red : new Color(.4f,.4f,1f); | |
gameObject.transform.position = _initializePos + input.LocalPosition; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment