private void updateInputs() { if (server == null) { return; } if ((supportedInputs & InputType.Cursors) != 0) { server.AddDataProcessor(cursorProcessor); } else { server.RemoveDataProcessor(cursorProcessor); } if ((supportedInputs & InputType.Blobs) != 0) { server.AddDataProcessor(blobProcessor); } else { server.RemoveDataProcessor(blobProcessor); } if ((supportedInputs & InputType.Objects) != 0) { server.AddDataProcessor(objectProcessor); } else { server.RemoveDataProcessor(objectProcessor); } }
//private void Update() //{ // if (Input.GetMouseButton(0)) // { // Debug.Log(Input.mousePosition); // } //} private void OnEnable() { Debug.Log(string.Format("TUIO listening on port {0}... (Press escape to quit)", port)); if (IsShowTip) { if (_tipObjects.Count == 0) { GameObject prefab = new GameObject("tip", typeof(Image)); Canvas canvas = FindObjectOfType <Canvas>(); for (int i = 0; i < 15; i++) { GameObject go = Instantiate(prefab, canvas.transform); Image image = go.GetComponent <Image>(); image.rectTransform.position = Vector3.zero; _tipObjects.Add(image); go.SetActive(false); } } } _screenWidth = Screen.width; _screenHeight = Screen.height; // tuio 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... Connect(); _tuioServer.AddDataProcessor(cursorProcessor); _tuioServer.AddDataProcessor(blobProcessor); _tuioServer.AddDataProcessor(objectProcessor); Debug.Log("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!"); }
//添加tuio解析器 private void InitProcessor() { if (mServer == null) { return; } mObjectProcessor = new ObjectProcessor(); mObjectProcessor.ObjectAdded += OnObjectAdded; mObjectProcessor.ObjectUpdated += OnObjectUpdated; mObjectProcessor.ObjectRemoved += OnObjectRemoved; mServer.AddDataProcessor(mObjectProcessor); }
private void OnEnable() { Debug.Log(string.Format("TUIO listening on port {0}... (Press escape to quit)", port)); screenWidth = Screen.width; screenHeight = Screen.height; // tuio 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... connect(); tuioServer.AddDataProcessor(cursorProcessor); tuioServer.AddDataProcessor(blobProcessor); tuioServer.AddDataProcessor(objectProcessor); Debug.Log("connect"); }
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); //处理器添加 }