void Update()
    {
        try
        {
            if (listRecvStr.Count != 0)
            {
                //oldListRecStr = listRecvStr;
                //recOrNot = false;
                foreach (string recvFinal in listRecvStr)
                {
                    //print(recvFinal + count_plantSet.ToString());
                    JSONNode jData = JSON.Parse(recvFinal);
                    //print(jData);
                    string header = jData["header"];
                    if (header == "ps")
                    {
                        PlantSet ps = JsonUtility.FromJson <PlantSet>(recvFinal);
                        //PlantSet ps = JsonConvert.DeserializeObject<PlantSet>(recvFinal);
                        GameObject plantSetWant = GameObject.Find(ps.Name);
                        mpUI.GeneratePlantAnchor(ps.Name, ps.pos, ps.rotate, true);
                    }

                    else if (header == "pds")
                    {
                        GameObject singlePlant = FindSinglePlant(jData["singName"], jData["singId"]);
                        UpdateSingPlant(singlePlant, jData, true);
                    }

                    else if (header == "pds_sync")
                    {
                        GameObject singlePlant = FindSinglePlant(jData["singName"], jData["singId"]);
                        UpdateSingPlant(singlePlant, jData, false);
                    }

                    else if (header == "PN")
                    {
                        plantSetNum = int.Parse(jData["PlantNumber"]);
                    }

                    else if (header == "wa")
                    {
                        WorldAnchorTrans wat = JsonUtility.FromJson <WorldAnchorTrans>(recvFinal);
                        anchorData = wat.data;
                        Debug.Log("download anchor with tcp successfully");
                    }
                }
                listRecvStr = new List <string>();
            }
        }
        catch (Exception e)
        {
            print("Error happens here:" + e);
        }
    }
Exemple #2
0
 public void SyncWorldAnchor()
 {
     trigger = true;
     indicator.GetComponent <MeshRenderer>().material.color = Color.yellow;
     startWaTime.text = Time.time.ToString();
     plantNum         = int.Parse(IF.text);
     for (int i = 0; i < plantNum; i++)
     {
         TextAsset asset = Resources.Load("AnchorData/" + PlantNameList[i]) as TextAsset;
         anchorData = asset.bytes;
         anchorId   = PlantNameList[i];
         GameObject plantUI = mpUI.GeneratePlantAnchor(anchorId, Vector3.zero, Vector3.zero, false);
         plantUI.GetComponent <SyncSinglePlant>().StartSyncSinglePlant(anchorData, indicator);
     }
 }
Exemple #3
0
    public void StartLocatingPant()
    {
        GameObject UIcontainer = mpUI.GeneratePlantAnchor(plantName, transform.position, transform.eulerAngles, false);
        //GameObject UIcontainer = GameObject.Find(plantName);
        PlantSet pObject = new PlantSet
        {
            Name   = plantName,
            rotate = UIcontainer.transform.localEulerAngles,
            pos    = UIcontainer.transform.localPosition,
            header = "ps"
        };
        //tCP.SocketSendByte(pObject);


        //foreach (Transform uiWhole in UIcontainer.transform.GetChild(0))
        //{
        //    GameObject button = uiWhole.GetChild(0).GetChild(4).gameObject;
        //    button.GetComponent<Interactable>().OnClick.Invoke();
        //}
    }