void ProcessPosition(string tagID, Vector3 pos) { GameObject tag = null; try { tag = GameObject.FindGameObjectsWithTag(TagDefs.TAG_TAG).Where(t => tagID == t.name).First(); } catch (Exception) { tag = Instantiate(TagPrefab, new Vector3(0, 0.5f, 0), Quaternion.identity) as GameObject; tag.name = tagID; } TagMove tagScript = tag.GetComponent <TagMove> (); if (tagScript != null) { tagScript.Move(pos); } }
private void UpdateTag(string tagID, List <AnchorInfoPacket> packets) { if (packets.Count < 3) { throw new ArgumentException("Must have at least 3 packets. " + packets.Count.ToString() + "were provided."); } Vector3 newTagPosition = CalculateTagPositionByPackets(packets); GameObject tag = null; try { tag = GameObject.FindGameObjectsWithTag(TagDefs.TAG_TAG).Where(t => tagID == t.name).First(); } catch (Exception) { } if (tag == null) { tag = Instantiate(TagPrefab, new Vector3(0, 0.5f, 0), Quaternion.identity) as GameObject; tag.name = tagID; } // CPTagPositioner tagScript = (CPTagPositioner)tag.GetComponent(typeof(CPTagPositioner)); // if(tagScript != null) { // tagScript.AddPosition(newTagPosition); // } TagMove tagScript = tag.GetComponent <TagMove> (); if (tagScript != null) { tagScript.Move(newTagPosition); } }