private void Connect() { if (!Application.isPlaying) { return; } if (_tuioServer != null) { Disconnect(); } if (Instance != null) { throw new UnityException("不允许多个单例"); } Instance = this; _tuioServer = new TuioServer(port); _waitForEndOfFrame = new WaitForEndOfFrame(); _coroutine = StartCoroutine(EndFrame()); Debug.Log("TUIO Port" + port); _tuioServer.Connect(); Debug.Log("TUIO Connect"); }
/// <inheritdoc /> protected override void Start() { base.Start(); server = new TuioServer(TuioPort); server.MovementThreshold = MovementThreshold * TouchManager.Instance.DotsPerCentimeter / Mathf.Max(Screen.width, Screen.height); server.CursorAdded += OnCursorAdded; server.CursorUpdated += OnCursorUpdated; server.CursorRemoved += OnCursorRemoved; server.Connect(); }
/// <inheritdoc /> protected override void OnEnable() { base.OnEnable(); server = new TuioServer(TuioPort); server.MovementThreshold = MovementThreshold * manager.DotsPerCentimeter / Mathf.Max(Screen.width, Screen.height); server.CursorAdded += OnCursorAdded; server.CursorUpdated += OnCursorUpdated; server.CursorRemoved += OnCursorRemoved; server.Connect(); }
private void connect() { if (!Application.isPlaying) { return; } if (server != null) { disconnect(); } server = new TuioServer(TuioPort); server.Connect(); updateInputs(); }
//监听端口 private void Connect() { if (!Application.isPlaying) { return; } if (mServer != null) { Disconnect(); } mServer = new TuioServer(tuioPort); mServer.Connect(); InitProcessor(); }
private Vector2 screen; //屏幕长宽值 private void OnEnable() //启动 { screen.x = Screen.width; screen.y = Screen.height; cursorProcessor = new CursorProcessor();//委托挂载到线程里 cursorProcessor.CursorAdded += OnCursorAdded; cursorProcessor.CursorUpdated += OnCursorUpdated; cursorProcessor.CursorRemoved += OnCursorRemoved; server = new TuioServer(TuioPort); //启动服务 server.Connect(); //连接 server.AddDataProcessor(cursorProcessor); //处理器添加 }
private void connect() { if (!Application.isPlaying) { return; } if (tuioServer != null) { disconnect(); } tuioServer = new TuioServer(port); Debug.Log("TUIO Port" + port); tuioServer.Connect(); Debug.Log("TUIO Connect"); }
private static void ListenForTUIO() { Console.WriteLine(string.Format("TUIO listening on port {0}... (Press escape to quit)", port)); // tuio tuioServer = new TuioServer(port); CursorProcessor cursorProcessor = new CursorProcessor(); cursorProcessor.CursorAdded += OnCursorAdded; cursorProcessor.CursorUpdated += OnCursorUpdated; cursorProcessor.CursorRemoved += OnCursorRemoved; BlobProcessor blobProcessor = new BlobProcessor(); blobProcessor.BlobAdded += OnBlobAdded; blobProcessor.BlobUpdated += OnBlobUpdated; blobProcessor.BlobRemoved += OnBlobRemoved; ObjectProcessor objectProcessor = new ObjectProcessor(); objectProcessor.ObjectAdded += OnObjectAdded; objectProcessor.ObjectUpdated += OnObjectUpdated; objectProcessor.ObjectRemoved += OnObjectRemoved; // listen... tuioServer.Connect(); tuioServer.AddDataProcessor(cursorProcessor); tuioServer.AddDataProcessor(blobProcessor); tuioServer.AddDataProcessor(objectProcessor); do { while (!Console.KeyAvailable) { Thread.Sleep(100); } } while (Console.ReadKey(true).Key != ConsoleKey.Escape); // done tuioServer.Disconnect(); tuioServer = null; Console.WriteLine("Bye!"); }