Пример #1
0
    void Update()
    {
        handPosList = dealWithUDPMessage.GetHandPos();



        if (nodes.Count < handPosList.Count)
        {
            CreateNode();
        }

        if (nodes.Count > handPosList.Count)
        {
            //if (threadOnOff)
            //{
            //    Debug.Log("off");

            //        loop = false;
            //        m_thread.Abort();

            //    threadOnOff = false;
            //}



            for (int i = 0; i < nodes.Count; i++)
            {
                if (i >= handPosList.Count)
                {
                    Destroy(nodes[i].gameObject, .2f);

                    nodes.RemoveAt(i);
                }
            }
            //if (!threadOnOff)
            //{// 线程开关
            //    Debug.Log("on");
            //    m_thread = new Thread(() => UpdateThread(nodes));
            //    loop = true;
            //    m_thread.Start();

            //    threadOnOff = true;

            //}
        }


        foreach (HandPos HandPos in handPosList)
        {
            if (handPosList.Count != 0)
            {
                Vector3 pos = new Vector3(HandPos.x - xoffset, -HandPos.y + yoffset);

                try
                {
                    if (handPosList.IndexOf(HandPos) <= nodes.Count - 1)
                    {
                        nodes[handPosList.IndexOf(HandPos)].transform.localPosition = pos;
                    }
                }
                catch (System.Exception message)
                {
                    throw message;
                }
            }
        }

        //UpdateThread();
    }