Skip to content

Instantly share code, notes, and snippets.

@KzoNag
Created December 14, 2022 11:15
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 KzoNag/be803ea5cef68807b68ea4674e7410d6 to your computer and use it in GitHub Desktop.
Save KzoNag/be803ea5cef68807b68ea4674e7410d6 to your computer and use it in GitHub Desktop.
ブログ用 - ハンドトラッキングデバイスの追加
public class HandDeviceSupport : MonoBehaviour
{
private InputDevice _rightDevice, _leftDevice;
private void OnEnable()
{
_rightDevice = InputSystem.AddDevice<HandDevice>("HandDevice - Right");
if(_rightDevice != null)
{
InputSystem.SetDeviceUsage(_rightDevice, CommonUsages.RightHand);
}
_leftDevice = InputSystem.AddDevice<HandDevice>("HandDevice - Left");
if(_leftDevice != null)
{
InputSystem.SetDeviceUsage(_leftDevice, CommonUsages.LeftHand);
}
}
private void OnDisable()
{
if(_rightDevice != null && _rightDevice.added)
{
InputSystem.RemoveDevice(_rightDevice);
_rightDevice = null;
}
if(_leftDevice != null && _leftDevice.added)
{
InputSystem.RemoveDevice(_leftDevice);
_leftDevice = null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment