void UpdateHeadPosByInput()
float mouse_x = Input.GetAxis("Mouse X") * HeadRotateSpeed;
float mouse_y = Input.GetAxis("Mouse Y") * HeadRotateSpeed;
Vector3 mouseMove = new Vector3(m_CameraTarget.transform.eulerAngles.x - mouse_y, m_CameraTarget.transform.eulerAngles.y + mouse_x, 0);
Quaternion q = Quaternion.Euler(mouseMove);
m_CameraTarget.transform.rotation = q;
Vector3 p = GetBaseInput();
p = p * HeadMoveSpeed * Time.deltaTime;
Vector3 pos = p + m_CameraTarget.transform.position;
m_CameraTarget.transform.position = pos;
// Call api to simulate the headpose movement
NREmulatorManager.Instance.NativeEmulatorApi.SetHeadTrackingPose(pos, q);
Sample Code: NREmulatorController.cs
// Control the rotation of controller
void UpdateControllerRotateByInput()
float mouse_x = Input.GetAxis("Mouse X") * HeadRotateSpeed;
float mouse_y = Input.GetAxis("Mouse Y") * HeadRotateSpeed;
Vector3 mouseMove = new Vector3(m_Target.transform.eulerAngles.x - mouse_y, m_Target.transform.eulerAngles.y + mouse_x, 0);
Quaternion q = Quaternion.Euler(mouseMove);
m_Target.transform.rotation = q;
NREmulatorManager.Instance.NativeEmulatorApi.SetControllerRotation(new Quaternion(q.x, q.y, q.z, q.w));
Run the Sample
First , Assets/NRSDk/Emulator/Scenes/TrackableImageEmulator.unity and Assets/NRSDk/Emulator/Scenes/TrackablePlaneEmulator.unity are two samples for the Emulator. Developers could directly play the scene in Unity Editor or build them into apk and run on an Nreal Device.
Create your own
Make sure you have Assets/NRSDK/Prefabs/NRCamreaRig.prefab and NRSDK/Prefabs/NRInput.prefab in the scene.
When Unity Editor under runtime, the NREmulatorHeadPose.prefab will be automatically loaded by NRCameraRig.prefab into the scene for simulating the head pose data.
When Unity Editor under runtime, theEmualatorController.Prefab will be automatically loaded by NRInput.prefab into the scene for simulating the controller input data.
Sample Code: TrackableFoundTest.cs
public class TrackableFoundTest : MonoBehaviour {
// Observer of the registed event
public TrackableObserver Observer;
// Showing GameObject on the detected Trackable object
public GameObject Obj;
void Start ()
Obj.SetActive(false);
Observer.FoundEvent += Found;
Observer.LostEent += Lost;
private void Found(Vector3 pos, Quaternion qua)
Obj.transform.position = pos;
Obj.transform.rotation = qua;
Obj.SetActive(true);
private void Lost()
Obj.SetActive(false);
In NRSDK, we provided you with three default images for image detection. If you would like to add your own, please find NRCameraRig.prefab
FindNRKernalSessionConfig.asset under the NRSessionBehaviour.cs