void Start()
    {
        CurrentEventObject.Display();
        Debug.Log("Number of events in EventScene: " + CurrentEventObject.orgs.Count);
        // CurrentEventObject.AddOrg("Bloomberg");
        // CurrentEventObject.AddOrg("Solidworks");

        // CurrentEventObject.ev = Instantiate(eventObject, Vector3.zero, Quaternion.identity);
        int numOfAreas = (CurrentEventObject.orgs.Count - 1) / orgsPerArea + 1;

        for (int i = 0; i < numOfAreas; i++)
        {
            GameObject a = Instantiate(areaObject, CurrentEventObject.positions[i], Quaternion.identity);
            for (int j = 0; j < orgsPerArea; j++)
            {
                int currentIndex = i * orgsPerArea + j;
                if (currentIndex >= CurrentEventObject.orgs.Count)
                {
                    break;
                }
                // Debug.Log("i: " + i + "\nj: " + j +"\ncurrentIndex: " + currentIndex);
                string currentOrgName = CurrentEventObject.orgs[currentIndex];
                getElements(currentOrgName, snapshot =>
                {
                    // Debug.Log("Snapshot retrieved for: " + currentOrgName);
                    UnityMainThreadDispatcher.Instance().Enqueue(CreateExhibit(snapshot, a, j));
                });
            }

            a.transform.SetParent(eventObject.transform);
        }
        UnityMainThreadDispatcher.Instance().Enqueue(FinishLoading());
    }
예제 #2
0
    private IPromise ConnectToFirebase()
    {
        var promise = new Promise();
        DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;

        FirebaseDatabase.DefaultInstance.GetReference("events/" + code_Input.text).GetValueAsync().ContinueWith(task =>
        {
            if (task.IsFaulted)
            {
                Debug.Log("error");
                promise.Reject(task.Exception);
            }
            else if (task.IsCompleted)
            {
                DataSnapshot snapshot = task.Result;
                string ss             = snapshot.GetRawJsonValue().ToString();
                Debug.Log("Raw Json: " + ss);
                // dynamic data = JsonConvert.DeserializeObject<dynamic>(ss);
                dynamic data = JsonConvert.DeserializeObject(ss);
                // Debug.Log(data);
                // CurrentEventObject.numOfOrgs = data["numOfOrgs"];

                Debug.Log(data["numOfOrgs"].Value.GetType());
                CurrentEventObject.eventId   = code_Input.text;
                CurrentEventObject.numOfOrgs = data["numOfOrgs"].Value;
                CurrentEventObject.uid       = data["uid"].Value;
                Debug.Log(data["orgs"].Count);
                foreach (JProperty org in (JToken)data["orgs"])
                {
                    CurrentEventObject.AddOrg(org.Value.ToString());
                }
                CurrentEventObject.Display();
                promise.Resolve();
            }
        });

        return(promise);
    }