private void Start() { arkitFacialValues = new ARKitFacialValues(); recorder = new ARKitFacialRecorder(); var oscParser = new Parser(); var server = new UdpServerProxy(port, (bytes, endPoint) => { oscParser.FeedData(bytes, bytes.Length); while (0 < oscParser.MessageCount) { var msg = oscParser.PopMessage(); OnReceivedOsc(msg); } }); Observable .EveryUpdate() .Subscribe(_ => { recorder.RecordUpdate(arkitFacialValues); arkitFacialControl.ApplyExternal(arkitFacialValues); if (text) { text.text = arkitFacialValues.ToString(); } }).AddTo(this); }
private void Start() { arkitFacialValues = new ARKitFacialValues(); recorder = new ARKitFacialRecorder(); Parser oscParser = new Parser(); var server = new UdpServerProxy <Queue <Message> >(port, (bytes, endPoint) => { oscParser.FeedData(bytes, bytes.Length); messageQueue.Clear(); while (0 < oscParser.MessageCount) { var msg = oscParser.PopMessage(); messageQueue.Enqueue(msg); } return(messageQueue); }); server.OnValueChanged() .SubscribeOn(Scheduler.ThreadPool) .Subscribe() .AddTo(this); Observable .EveryUpdate() .Where(_ => messageQueue.Count > 0) .Subscribe(_ => { for (int i = 0; i < messageQueue.Count; i++) { OnReceivedOsc(messageQueue.Dequeue()); } }).AddTo(this); Observable .EveryUpdate() .Subscribe(_ => { recorder.RecordUpdate(arkitFacialValues); arkitFacialControl.ApplyExternal(arkitFacialValues); if (text) { text.text = arkitFacialValues.ToString(); } }).AddTo(this); }