Exemple #1
0
    IEnumerator FetchSceneList(SceneSaveListLoaded callBack)
    {
        // Defer this function to the next frame until server replied and response has been downloaded
        UnityWebRequest req = UnityWebRequest.Get(string.Format("{0}/Scene", AssetManagement.Instance.AssetManager.ServerAddress));

        yield return(req.SendWebRequest());

        if (req.isHttpError || req.isNetworkError)
        {
            _lastError = req.error;

            Debug.Log(string.Format("Couldn't fetch SceneSave-List due to: {0}", req.error));

            if (callBack != null)
            {
                callBack(null);
            }
        }
        else
        {
            Debug.Log("Scene Manager: Scene list finished downloading.");

            SceneSaveListing listing = JsonUtility.FromJson <SceneSaveListing>(req.downloadHandler.text);

            if (callBack != null)
            {
                callBack(listing.SceneList);
            }
        }
    }
Exemple #2
0
 /// <summary>
 /// Queries the List of all previously saved Scenes and passes the list to the
 /// specified callback-method.
 /// </summary>
 /// <param name="callBack">
 /// Method which is called upon once the list has been fetched
 /// Callback will get a null-argument if an error occured while fetchting the list.
 /// </param>
 public void GetListOfSavedScenes(SceneSaveListLoaded callBack)
 {
     Debug.Log("Scene Manager: Requesting scene list from server...");
     StartCoroutine(FetchSceneList(callBack));
 }