Ejemplo n.º 1
0
    IEnumerator GetScene()
    {
        string url = string.Format("{0}/v2/api/docs/{1}/scenes/{2}", appConfig.demoServerURL, appConfig.modelID, scene);

        using (UnityWebRequest req = UnityWebRequest.Get(url))
        {
            req.SetRequestHeader("Authorization", "Bearer " + appConfig.accessToken);
            yield return(req.SendWebRequest());

            if (req.isNetworkError || req.isHttpError)
            {
                Debug.LogError(req.error);
                Dialog.Open(dialogPrefab.gameObject, DialogButtonType.OK, "Scene Loading Error", req.error);
                ProgressIndicator.Instance.Close();
            }
            else
            {
                string    json      = req.downloadHandler.text;
                SceneInfo sceneInfo = SceneInfo.CreateFromJSON(json);
                foreach (Transform transform in target.transform)
                {
                    Destroy(transform.gameObject);
                }
                Destroy(target.GetComponent <ForgeLoader>());
                ForgeLoader loader = ForgeLoader.AddLoaderToGameObject(target, sceneInfo.prj.urn, scene, appConfig.accessToken, false, true, true);
                loader.ProcessedNodes.AddListener(new UnityEngine.Events.UnityAction <float>(OnProcessingNodes));
                loader.ProcessingNodesCompleted.AddListener(new UnityEngine.Events.UnityAction <int>(OnProcessingNodesCompleted));
            }
        }
    }