An Interest In:
Web News this Week
- April 20, 2024
- April 19, 2024
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
February 14, 2022 07:48 am GMT
Original Link: https://dev.to/kara_d_en/handtracking-mr-tutorial-for-nreal-light-10ij
HandTracking - MR Tutorial for Nreal light
Sample Repository
Run the sample
- Clone Sample Repository, Change current directory to
HandTracking
. And Open with Unity. - Download NRSDK 1.7.0 from https://nreal-public.nreal.ai/download/NRSDKForUnityAndroid_1.7.0.unitypackage
- Open
Build Setting
, change Platform toAndroid
- Open
Project
, selectAssets
>import package
>Custom Package
and importNRSDKForUnityAndroid_1.7.0.unitypackage
. - Check
Build Settings
>Player Settings
by referring to Configure Build Settings - Press
Build
formBuild Settings
panel - Install *.apk on Android or DevKit.
Tutorial
1. Setting up the project for Nreal development
- See Quickstart for Android - NRSDK Documentation and configure the build settings.
- Download NRSDK 1.7.0 from https://nreal-public.nreal.ai/download/NRSDKForUnityAndroid_1.7.0.unitypackage
- Open
Project
, selectAssets
>import package
>Custom Package
and importNRSDKForUnityAndroid_1.7.0.unitypackage
.
2. Create Material
- Open
Project
, selectAssets
- Create
Material
onAssets
- Change name to TouchCubeMaterial
- Change
Albedo
to CC0000
3. Put Cube in the Scene
- Put
Cube
in the Scene- Change name to TouchCube
Pos X
: 0,Pos Y
: 0,Pos Z
: 8
4. Put a Canvas in the scene
- Put
Canvas
fromCreate
>UI
- Set property on
Inspector
panelRender Mode
: World SpacePos X
: 0 ,Pos Y
: -0.35Pos Z
: 3Scale
X
: 0.005 ,Y
: 0.005 ,Z
: 0.005
5. Put Text in Canvas
- Put
Text
as a child ofCanvas
with the name "Counter.Pos X
: 0,Pos Y
: -30,Pos Z
: 3- Change
Text
to 0 - Change
Color
to FFCC00 - Change Font size to 30
6. Create C# Script in Assets
- Create
C# Script
in the asset with the file name "HandTrack.cs". - Write the code as follows
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.EventSystems;using UnityEngine.UI;public class HandTrack : MonoBehaviour, IPointerClickHandler{ /// <summary> /// Counter Text GameObject /// </summary> public Text targetText; /// <summary> /// Counter value /// </summary> private int counter = 0; /// <summary> /// HandTracking Click Handler /// </summary> /// <param name="eventData"></param> public void OnPointerClick(PointerEventData eventData) { counter++; targetText.text = counter.ToString(); //throw new System.NotImplementedException(); } // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { }}
7. Attach the C# script on TouchCube
- Attach "HandTrack.cs" to TouchCube
- Set
Target Text
onInspector
panel toCounter
on the scene.
- Set
8. Build
- Press
Build
formBuild Settings
panel - Install *.apk on Android or DevKit.
Original Link: https://dev.to/kara_d_en/handtracking-mr-tutorial-for-nreal-light-10ij
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To