Exemple #1
0
        IEnumerator DoLoad()
        {
            Debug.Log("Loading...");

            // Disable load button.
            loadButton.interactable = false;
            // SaveGameWeb web = new SaveGameWeb(url, secretKey, usernameInputField.text, passwordInputField.text);
            SaveGameWeb web = new SaveGameWeb(url, secretKey, userName, password);
            yield return StartCoroutine(web.Download(identifier));

            // Enable load button.
            loadButton.interactable = true;
#if UNITY_2017_1_OR_NEWER
            if ( web.Request.isHttpError || web.Request.isNetworkError )
			{
                Debug.LogError("Load Failed");
                Debug.LogError(web.Request.error);
                Debug.LogError(web.Request.downloadHandler.text);
            }
            else
            {
                Debug.Log("Load Successful");
                Debug.Log("Response: " + web.Request.downloadHandler.text);
                //dataInputField.text = web.Load<string>(defaultValue);
                SaveItemsList loadItems = new SaveItemsList();
                loadItems = JsonUtility.FromJson<SaveItemsList>(web.Load<string>(defaultValue)) ;
                Debug.Log(loadItems.saveList[0].tag);
                foreach(SaveItems item in loadItems.saveList)
                {
                    foreach(GameObject prefab in prefabList)
                    {
                        if (prefab.tag == item.tag)
                        {
                            GameObject tileAdded = (GameObject)Instantiate(prefab, item.pos, item.rot);
                            //objLoad.PushItem(tileAdded);
                            //if (scrollList != null)
                            //    scrollList.TryTransferItemToOtherShop(cartItem);
                            tileAdded.transform.parent = GameObject.FindGameObjectWithTag("Manager").transform;
                        }
                    }
                }
            }
#else
            if (web.Request.isError)
            {
                Debug.LogError("Load Failed");
                Debug.LogError(web.Request.error);
                Debug.LogError(web.Request.downloadHandler.text);
            }
            else
            {
                Debug.Log("Load Successful");
                Debug.Log("Response: " + web.Request.downloadHandler.text);
                dataInputField.text = web.Load<string>(defaultValue);
            }
#endif
        }
        IEnumerator DoLoad()
        {
            Debug.Log("Loading...");

            // Disable load button.
            loadButton.interactable = false;
            SaveGameWeb web = new SaveGameWeb(url, secretKey, usernameInputField.text, passwordInputField.text);

            yield return(StartCoroutine(web.Download(identifier)));

            // Enable load button.
            loadButton.interactable = true;
#if UNITY_2017_1_OR_NEWER
            if (web.Request.isHttpError || web.Request.isNetworkError)
            {
                Debug.LogError("Load Failed");
                Debug.LogError(web.Request.error);
                Debug.LogError(web.Request.downloadHandler.text);
            }
            else
            {
                Debug.Log("Load Successful");
                Debug.Log("Response: " + web.Request.downloadHandler.text);
                dataInputField.text = web.Load <string>(defaultValue);
            }
#else
            if (web.Request.isError)
            {
                Debug.LogError("Load Failed");
                Debug.LogError(web.Request.error);
                Debug.LogError(web.Request.downloadHandler.text);
            }
            else
            {
                Debug.Log("Load Successful");
                Debug.Log("Response: " + web.Request.downloadHandler.text);
                dataInputField.text = web.Load <string>(defaultValue);
            }
#endif
        }
Exemple #3
0
        private IEnumerator LoadEnumerator()
        {
            Debug.Log("Downloading...");
            var web = new SaveGameWeb(
                username,
                password,
                url,
                encode,
                encodePassword,
                SerializerDropdown.Singleton.ActiveSerializer);

            yield return(StartCoroutine(web.Download(identifier)));

            target.position = web.Load <Vector3Save>(identifier, Vector3.zero);
            Debug.Log("Download Done.");
        }