File -> New Scene
File -> Save Scene as ... -> Sample03.unity
from above menu -> "Assets" -> "Create" -> "C# Script" -> Rename as "Sample03"
Sample03.cs |
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Sample03 : MonoBehaviour { public GameObject target; NtUnity.Kinect nt; Texture2D texture; void Start () { nt = new NtUnity.Kinect(); texture = new Texture2D(NtUnity.Kinect.rgbCols, NtUnity.Kinect.rgbRows, TextureFormat.RGBA32,false); } void Update () { nt.setRGB(); texture.SetPixels32(nt.rgbImage); texture.Apply(); target.GetComponent<Renderer>().material.mainTexture = texture; // rotate cube target.transform.rotation = Quaternion.AngleAxis(Mathf.Rad2Deg * Time.time, Vector3.up); } void OnApplicationQuit() { nt.stopKinect(); } } |
above Menu -> GameObject -> 3D Object -> Cube
above Menu -> GameObject -> Create Empty
The cycle at which the cube makes one rotation around the y-axis is about 6.3 seconds (= 2π seconds).
Runtime Video UnityDLL03.mp4