MotionCapture/Assets/CubeBehaviour.cs
jackfiled d38b44b8ac 接收Udp数据
附赠3D立方体旋转一小时
2023-02-10 16:17:18 +08:00

39 lines
846 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Models;
using UnityEngine;
public class CubeBehaviour : MonoBehaviour
{
public Vector3 rotateAmount = new Vector3(0, 1, 0);
private readonly UdpListener _listener = new UdpListener();
// Start is called before the first frame update
private void Start()
{
_listener.AddHandler(LogLandmarks);
_listener.Connect(5000);
}
// Update is called once per frame
private void Update()
{
transform.Rotate(rotateAmount);
}
private void OnDisable()
{
_listener.DisConnect();
}
private static void LogLandmarks(List<PoseLandmark> landmarks)
{
foreach (var landmark in landmarks)
{
Debug.Log(landmark.ToString());
}
}
}