Exemple #1
0
        private void disconnect()
        {
            if (server != null)
            {
                server.RemoveAllDataProcessors();
                server.Disconnect();
                server = null;
            }

            foreach (var i in cursorToInternalId)
            {
                cancelPointer(i.Value);
            }
            foreach (var i in blobToInternalId)
            {
                cancelPointer(i.Value);
            }
            foreach (var i in objectToInternalId)
            {
                cancelPointer(i.Value);
            }
            cursorToInternalId.Clear();
            blobToInternalId.Clear();
            objectToInternalId.Clear();
        }
Exemple #2
0
    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");
    }
Exemple #3
0
 void disconnect()
 {
     if (tuioServer != null)
     {
         tuioServer.RemoveAllDataProcessors();
         tuioServer.Disconnect();
         tuioServer = null;
     }
 }
Exemple #4
0
 //停止监听
 private void Disconnect()
 {
     if (mServer != null)
     {
         mServer.RemoveAllDataProcessors();
         mServer.Disconnect();
         mServer = null;
     }
     mMarkerDictionary.Clear();
 }
Exemple #5
0
 private void OnDisable()//关闭
 {
     if (server != null)
     {
         server.RemoveDataProcessor(cursorProcessor);
         server.RemoveAllDataProcessors();
         server.Disconnect();
         server = null;
     }
 }
Exemple #6
0
        /// <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();
        }
Exemple #7
0
        /// <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();
        }
Exemple #8
0
        private void disconnect()
        {
            if (server != null)
            {
                server.RemoveAllDataProcessors();
                server.Disconnect();
                server = null;
            }

            foreach (var i in cursorToInternalId)
            {
                cancelTouch(i.Value.Id);
            }
        }
Exemple #9
0
        private void connect()
        {
            if (!Application.isPlaying)
            {
                return;
            }
            if (server != null)
            {
                disconnect();
            }

            server = new TuioServer(TuioPort);
            server.Connect();
            updateInputs();
        }
Exemple #10
0
    //监听端口
    private void Connect()
    {
        if (!Application.isPlaying)
        {
            return;
        }
        if (mServer != null)
        {
            Disconnect();
        }

        mServer = new TuioServer(tuioPort);
        mServer.Connect();
        InitProcessor();
    }
Exemple #11
0
        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); //处理器添加
        }
Exemple #12
0
        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");
        }
Exemple #13
0
 private void Disconnect()
 {
     if (_tuioServer != null)
     {
         _tuioServer.RemoveAllDataProcessors();
         _tuioServer.Disconnect();
         _tuioServer        = null;
         _waitForEndOfFrame = null;
         if (_coroutine != null)
         {
             StopCoroutine(_coroutine);
         }
         _coroutine = null;
         Instance   = null;
     }
 }
Exemple #14
0
        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!");
        }
Exemple #15
0
 public TuioSample()
 {
     this.server = new TuioServer();
 }