Beispiel #1
0
    /* Retrieves the server maintained state of the world,
     * for known GameObjects, updates their positions. For new objects,
     * places them into the world and then removes UnityARHitTestExample script
     * which prevents the user from modifying them. This way, a user cannot move
     * objects created by another user.
     */
    public IEnumerator WaitForWorldSync(WWW www)
    {
        yield return(www);

        if (www.error != null)
        {
            Debug.Log("WWW Error: " + www.error);
            yield break;
        }

        RootObject root = RootObject.CreateFromJSON(www.text);

        Debug.Log("WORLD SYNC: " + root.objects.Count);

        foreach (VectorInformation v in root.objects)
        {
            string  objectId = v.id;
            Vector3 otherPos = new Vector3(v.x, v.y, v.z);

            if (objectMap.ContainsKey(objectId))
            {
                GameObject obj = objectMap [objectId];

                Debug.Log("World Sync Object: " + objectId + " to position: " + otherPos.ToString());

                GameObject temp = new GameObject();
                temp.transform.position = otherPos + anchor.transform.position;
//				temp.transform.RotateAround (anchor.transform.position, Vector3.up, anchor.transform.rotation.eulerAngles.y);
                Vector3 newPos = temp.transform.position;

                obj.transform.position = newPos;
            }
            else
            {
                // create a new game object!
                GameObject other = Instantiate(multiplayerObjectPrefabTwo, otherPos + anchor.transform.position, Quaternion.identity);
                other.transform.localScale = new Vector3(0.05f, 0.05f, 0.05f);
                float rotationOffset = heading - root.rotation;

                other.transform.RotateAround(anchor.transform.position, Vector3.up, rotationOffset);

                objectMap.Add(objectId, other);
                reverseObjectMap.Add(other.GetInstanceID(), objectId);

                Component[] scripts = other.GetComponentsInChildren(typeof(UnityEngine.XR.iOS.UnityARHitTestExample), true);
                foreach (UnityEngine.XR.iOS.UnityARHitTestExample s in scripts)
                {
                    Destroy(s);
                }
            }
        }
    }
Beispiel #2
0
    // Calls Instagram API and gets data of recent posts
    private IEnumerator GetRequest(string uri)
    {
        using (UnityWebRequest webRequest = UnityWebRequest.Get(uri))
        {
            yield return(webRequest.SendWebRequest());

            if (webRequest.isNetworkError)
            {
                Debug.Log("Error: " + webRequest.error);
            }
            else
            {
                //Debug.Log(webRequest.downloadHandler.text);
                var ResponseObj  = RootObject.CreateFromJSON(webRequest.downloadHandler.text);
                var responseData = ResponseObj.data;
                FindLikesById(responseData);
            }
        }
    }
Beispiel #3
0
    private IEnumerator getTextCo(string URL)
    {
        WWW req = new WWW(URL);

        yield return(req);

        jsonResponse = RootObject.CreateFromJSON(req.text);

        yield return(jsonResponse);

        responseText.text = jsonResponse.name.ToUpper();

        StartCoroutine(getImageCo(jsonResponse.sprites.front_default));

        //Debug.Log("Number of moves: " + jsonResponse.moves.Count);

        //foreach (Move move in jsonResponse.moves)
        //{
        //    Debug.Log(move.move.name);
        //}
    }