/// <summary> /// Load localized text from file in the android. /// </summary> /// <param name="fileName"></param> IEnumerator LoadLocalizedTextOnAndroid(string fileName) { _localizedText = new Dictionary <string, string>(); string filePath; filePath = Path.Combine(Application.streamingAssetsPath, fileName); string dataAsJson; UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(filePath); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { dataAsJson = www.downloadHandler.text; LocalizationData loadedData = JsonUtility.FromJson <LocalizationData>(dataAsJson); for (int i = 0; i < loadedData.items.Length; i++) { _localizedText.Add(loadedData.items[i].key, loadedData.items[i].value); } _isReady = true; } }
/// <summary> /// /// </summary> public static void Create(string assetCode, string localVersion) { m_InfoReady = false; m_LatestVersion = null; m_AssetCode = assetCode; m_LocalVersion = localVersion; vp_UpdateDialog window = (vp_UpdateDialog)EditorWindow.GetWindow(typeof(vp_UpdateDialog), true); window.titleContent.text = "Check for Updates"; window.minSize = new Vector2(m_DialogSize.x, m_DialogSize.y); window.maxSize = new Vector2(m_DialogSize.x, m_DialogSize.y); window.position = new Rect( (Screen.currentResolution.width / 2) - (m_DialogSize.x / 2), (Screen.currentResolution.height / 2) - (m_DialogSize.y / 2), m_DialogSize.x, m_DialogSize.y); window.Show(); window.m_Icon = m_UFPSIcon; m_ReleaseNotesPath = "http://legacy.opsive.com/assets/UFPS/hub/assets/" + m_AssetCode + "/releasenotes"; #if UNITY_2018_3_OR_NEWER m_InfoFile = UnityEngine.Networking.UnityWebRequest.Get("http://legacy.opsive.com/assets/UFPS/content/assets/" + m_AssetCode + "/info.txt"); m_InfoFile.SendWebRequest(); #else m_InfoFile = new WWW("http://legacy.opsive.com/assets/UFPS/content/assets/" + m_AssetCode + "/info.txt"); #endif }
private IEnumerator downloadFileFromURL(string url, string destfile) { if (File.Exists(destfile)) { Debug.Log("File exist, abort downloading"); yield break; } using (UnityEngine.Networking.UnityWebRequest webRequest = UnityEngine.Networking.UnityWebRequest.Get(url)) { yield return(webRequest.SendWebRequest()); if (webRequest.isNetworkError) { Debug.Log("Error: " + webRequest.error); } else { using (BinaryWriter writer = new BinaryWriter(File.Open(destfile, FileMode.Create))) { writer.Write(webRequest.downloadHandler.data); } } } yield return(null); }
// Use this for initialization void Start() { string url = "http://172.23.28.228/hackheist/updateGameInformation.php"; PlayerPackage player = new PlayerPackage(); player.playerUsername = PlayerPrefs.GetString("identity"); char[] allKeys = PlayerPrefs.GetString("keyCards").ToCharArray(); char[] allBadges = PlayerPrefs.GetString("badges").ToCharArray(); int BadgeValue = (100 * (allBadges[0] + allBadges[1] + allBadges[2] + allBadges[3] + allBadges[4] + allBadges[5] + allBadges[6])); int KeyCardValue = (10 * (allKeys[0] + allKeys[1] + allKeys[2] + allKeys[3] + allKeys[4] + allKeys[5] + allKeys[6])); int ScoreValue = PlayerPrefs.GetInt("NumQuestionsCorrect") + BadgeValue + KeyCardValue; PlayerPrefs.SetInt("Score", ScoreValue); ScoreText.text = ScoreValue.ToString(); player.score = PlayerPrefs.GetInt("Score"); player.numOfCorrectQuestions = PlayerPrefs.GetInt("NumQuestionsCorrect"); player.keyCards = PlayerPrefs.GetString("keyCards"); player.badges = PlayerPrefs.GetString("badges"); string json = JsonUtility.ToJson(player); print(json); UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Put(url, json); www.SetRequestHeader("Content-Type", "application/json"); www.SendWebRequest(); }
/* * Coroutine that reads a file from the stored jar file path located at Assets/StreamingAssets * https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest.html */ IEnumerator ReadFromStreamingAssets(string file_name) { string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, file_name); byte[] result; if (filePath.Contains("://") || filePath.Contains(":///")) { //read jar file path UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(filePath); yield return(www.SendWebRequest()); result = www.downloadHandler.data; } else { //read like a normal filepath result = System.IO.File.ReadAllBytes(filePath); } BuildMap(result); //write to Android/data/com.company.DoomMaze/files (copies the file) File.WriteAllBytes(Application.persistentDataPath + "/" + file_name, result); }
IEnumerator Register() { string username = usernameInput.text; WWWForm form = new WWWForm(); form.AddField("username", username); form.AddField("password", passwordInput.text); UnityEngine.Networking.UnityWebRequest request = UnityEngine.Networking.UnityWebRequest.Post("http://ec2-18-237-89-43.us-west-2.compute.amazonaws.com/register/", form); yield return(request.SendWebRequest()); if (request.responseCode == 200) { statusText.text = "<color=green>Account created!</color>"; loginUI.mainLoginButton.interactable = false; LoginManager.instance.loggedIn = true; LoginManager.instance.user = username; yield return(new WaitForSeconds(2.0f)); loginUI.registerPanel.SetActive(false); loginUI.mainLoginText.text = "Welcome, " + LoginManager.instance.user; } else { statusText.text = "<color=red>Register failed : " + request.downloadHandler.text + "</color>"; yield return(new WaitForSeconds(2.0f)); statusText.gameObject.SetActive(false); inputFields.SetActive(true); submitButton.SetActive(true); } usernameInput.text = ""; passwordInput.text = ""; }
public static void Load() { string path = Application.streamingAssetsPath + "/Room.json"; string jsonString; #if UNITY_EDITOR || UNITY_STANDALONE_WIN jsonString = File.ReadAllText(path); #elif UNITY_ANDROID UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(path); www.SendWebRequest(); while (!www.isDone) { } jsonString = www.downloadHandler.text; #endif var dataList = JsonConvert.DeserializeObject <List <RootObject> >(jsonString); for (int i = 0; i < dataList.Count; i++) { for (int j = 0; j < dataList[i].Probability_1; j++) { dataList[i].TreasureList.Add(dataList[i].Treasure_1); } for (int j = 0; j < dataList[i].Probability_2; j++) { dataList[i].TreasureList.Add(dataList[i].Treasure_2); } for (int j = 0; j < dataList[i].Probability_3; j++) { dataList[i].TreasureList.Add(dataList[i].Treasure_3); } _dataDic.Add(dataList[i].ID, dataList[i]); } }
public IEnumerator loadBundle() { boss = PersistantManager.Instance; string uri = "file:///" + Application.dataPath + "/AssetBundles/" + assetBundleName; UnityEngine.Networking.UnityWebRequest request = UnityEngine.Networking.UnityWebRequest.GetAssetBundle(uri, 0); yield return(request.SendWebRequest()); // yield return request.Send(); AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request); //ssrp_response_string = bundle.Load<>; TextAsset charDataFile2 = bundle.LoadAsset(fileName) as TextAsset; ssrp_response_string = charDataFile2.text; response_raw = (SSRP_response_raw)Deserialize(typeof(SSRP_response_raw), ssrp_response_string); boss.entityManager.importEntity(response_raw.contextResponses); /* * GameObject cube = bundle.LoadAsset<GameObject>("Cube"); * * GameObject sprite = bundle.LoadAsset<GameObject>("Sprite"); * Instantiate(cube); * Instantiate(sprite); * // */ }
//public void LoadLocalizedText(string fileName) //{ // localizedText = new Dictionary<string, string>(); // string filePath = Path.Combine(Application.streamingAssetsPath, fileName); // if (!File.Exists(filePath)) // { // filePath = Path.Combine(Application.streamingAssetsPath, "localizedText_en.json"); // } // string dataAsJson = File.ReadAllText(filePath); // Debug.Log("dataAsJson: " + dataAsJson); // LocalizationData loadedData = JsonUtility.FromJson<LocalizationData>(dataAsJson); // Debug.Log("loadedData.Items.Length: " + loadedData.Items.Length); // for (int i = 0; i < loadedData.items.Length; i++) // { // localizedText.Add(loadedData.items[i].key, loadedData.items[i].value); // } // Debug.Log(filePath + " Data loaded, dictionary contains: " + localizedText.Count + " entries"); // LocalizationManagerIsReady = true; //} //public IEnumerator LoadLocalizedText(string fileName) //{ // localizedText = new Dictionary<string, string>(); // var filePath = Path.Combine(Application.streamingAssetsPath + "/", fileName); // string dataAsJson; // if (filePath.Contains("://") || filePath.Contains(":///")) // { // UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(filePath); // yield return www.SendWebRequest(); // dataAsJson = www.downloadHandler.text; // } // else // { // dataAsJson = File.ReadAllText(filePath); // } // LocalizationData loadedData = JsonUtility.FromJson<LocalizationData>(dataAsJson); // for (int i = 0; i < loadedData.items.Length; i++) // { // localizedText.Add(loadedData.items[i].key, loadedData.items[i].value); // } // LocalizationManagerIsReady = true; //} public IEnumerator LoadLocalizedText(string fileName) { localizedTextAll = new Dictionary <string, string>(); foreach (var file in listLocalizedFile) { var filePath = Path.Combine(Application.streamingAssetsPath + "/", file); string dataAsJson; if (filePath.Contains("://") || filePath.Contains(":///")) { UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(filePath); yield return(www.SendWebRequest()); dataAsJson = www.downloadHandler.text; } else { dataAsJson = File.ReadAllText(filePath); } LocalizationData loadedData = JsonUtility.FromJson <LocalizationData>(dataAsJson); for (int i = 0; i < loadedData.items.Length; i++) { localizedTextAll.Add(file + "_" + loadedData.items[i].key, loadedData.items[i].value); Debug.Log("localizedTextAll.Add " + file + "_" + loadedData.items[i].key + ", " + loadedData.items[i].value); } } LocalizationManagerIsReady = true; }
// Download an AssetBundle public static IEnumerator downloadAssetBundle(string url, int version, string name) { string keyName = name; if (dictAssetBundleRefs.ContainsKey(keyName)) { yield return(null); } else { while (!Caching.ready) { yield return(null); } //using (WWW www = WWW.LoadFromCacheOrDownload(url, version)) //{ // yield return www; // if (www.error != null) // throw new Exception("WWW download:" + www.error); // AssetBundleRef abRef = new AssetBundleRef(url, version); // abRef.assetBundle = www.assetBundle; // dictAssetBundleRefs.Add(keyName, abRef); //} string uriAR = url; UnityEngine.Networking.UnityWebRequest requestAR = UnityEngine.Networking.UnityWebRequestAssetBundle.GetAssetBundle(uriAR); yield return(requestAR.SendWebRequest()); AssetBundle myLoadedAssetBundleAR = DownloadHandlerAssetBundle.GetContent(requestAR); AssetBundleRef abRef = new AssetBundleRef(url, version); abRef.assetBundle = myLoadedAssetBundleAR; dictAssetBundleRefs.Add(keyName, abRef); } }
public void GetARData() { AssetBundle bundle = AssetBundleManager.getAssetBundle(assetName + "-ar"); if (!bundle)//if not found in app cache/ was not loaded in this app session { Debug.Log("found AR asset on app cache"); AssetBundle bundleFromCache = AssetBundleManager.GetBundleFromCache(assetName + "-ar"); if (bundleFromCache)//then load the assetbundle from the file of fole exit { Debug.Log("found AR asset on disk"); AddARAssetBundleToList(bundleFromCache); UnityEngine.SceneManagement.SceneManager.LoadScene("3-AR-Character"); } else { Debug.Log("did not find AR asset on disk. Downloading asset"); string uriAR = BaseURL + assetName + "-ar"; UnityEngine.Networking.UnityWebRequest requestAR = UnityWebRequest.Get(uriAR); requestAR.SendWebRequest(); StartCoroutine(ShowProgress(uriAR, requestAR)); } } else { UnityEngine.SceneManagement.SceneManager.LoadScene("3-AR-Character"); } }
public void DownloadStoryFromURL(int index) { //assetname is ket same as prefab /gameobject name appManager.characterId = assetName; AssetBundle bundle = AssetBundleManager.getAssetBundle(assetName); if (!bundle)//if not found in app cache/ was not loaded in this app session { string uri = "https://s3-ap-southeast-1.amazonaws.com/vaanarsena/" + assetName; AssetBundle bundleFromCache = AssetBundleManager.GetBundleFromCache(assetName); if (bundleFromCache)//then load the assetbundle from the file of fole exit { InstantiateStoryAndAddtoList(bundleFromCache, index); } else { UnityEngine.Networking.UnityWebRequest request = UnityWebRequest.Get(uri); request.SendWebRequest(); StartCoroutine(ShowCircularProgress(index, uri, request)); } } else { Instantiate(bundle.LoadAsset(assetName), Stories[index].transform); Stories[index].SetActive(true); ARBtn.gameObject.SetActive(true); } }
IEnumerator loadResourcesList(UnityEngine.Networking.UnityWebRequest www, System.Action <bool, float, string> action) { var op = www.SendWebRequest(); while (!op.isDone) { action(false, 0.5f * op.progress, null); yield return(null); } if (string.IsNullOrEmpty(www.error)) { var text = www.downloadHandler.text; yield return(startThreadHandleResourcePackage(text, (isdone, progress, error) => { if (isdone) { action(true, 1, error); return; } action(false, 0.5f + 0.5f * progress, null); })); } else { action(false, 1, null); NextFrame(() => action(true, 1, KSwordKitName + ": " + www.error)); } }
private IEnumerator GetTextContentWWW(string[] paths, TextContainer container) { container.content = new string[paths.Length]; for (int i = 0; i < paths.Length; i++) { #if UNITY_STANDALONE || UNITY_EDITOR string filePath = "file://" + Path.Combine(Application.streamingAssetsPath, paths[i]); WWW www = new WWW(filePath); yield return(www); container.content[i] = www.text; #elif UNITY_ANDROID string filePath = "jar:file://" + Application.dataPath + "!/assets/" + paths[i].Replace("\\", "/"); WWW www = new WWW(filePath); yield return(www); container.content[i] = www.text; #elif UNITY_WEBGL string filePath = Path.Combine(Application.streamingAssetsPath, paths[i]).Replace("\\", "/"); //temp = filePath; UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(filePath); yield return(www.SendWebRequest()); //#if !UNITY_EDITOR // var bytes = System.Text.Encoding.UTF8.GetBytes(www.downloadHandler.text); // var text = System.Text.Encoding.UTF8.GetString(bytes, 3, bytes.Length - 3); // container.content[i] = text; //#else container.content[i] = www.downloadHandler.text; //#endif //temp += "\n"+ container.content[i]; #endif } }
IEnumerator ReadFromStreamingAssets() { string filePath = System.IO.Path.Combine(Application.streamingAssetsPath + "/", "testdata.txt"); // print(filePath); string result = ""; Debug.Log("reading . .. ."); if (filePath.Contains("://") || filePath.Contains(":///")) { UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(filePath); yield return(www.SendWebRequest()); result = www.downloadHandler.text; if (result == "") { test2.text = "F**K YOU"; } else { test2.text = result; } Debug.Log("DONE"); } else { result = System.IO.File.ReadAllText(filePath); test.text = "FAIL"; Debug.Log("FAIL"); } File.WriteAllText(Application.persistentDataPath + "/data.txt", result); // test2.text = Application.persistentDataPath; }
public static void Load() { string path = Application.streamingAssetsPath + "/Shop.json"; string jsonString; #if UNITY_EDITOR || UNITY_STANDALONE_WIN jsonString = File.ReadAllText(path); #elif UNITY_ANDROID UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(path); www.SendWebRequest(); while (!www.isDone) { } jsonString = www.downloadHandler.text; #endif var dataList = JsonConvert.DeserializeObject <List <RootObject> >(jsonString); _typeIdDic.Add(TypeEnum.Item, new List <RootObject>()); _typeIdDic.Add(TypeEnum.Equip, new List <RootObject>()); for (int i = 0; i < dataList.Count; i++) { _dataDic.Add(dataList[i].ID, dataList[i]); _typeIdDic[dataList[i].Type].Add(dataList[i]); } }
IEnumerator Upload(string uri, WWWForm form) { // WWWForm form = new WWWForm(); // form.AddField("username", "*****@*****.**"); // form.AddField("password", "test123"); UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Post(uri, form); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { WriteToObject($"Text {www.downloadHandler.text}"); Debug.Log("Form upload complete!"); Debug.Log($"Text {www.downloadHandler.text}"); Debug.Log($"Data {www.downloadHandler.data}"); } JsonUtility.ToJson(www.downloadHandler.data); }
private async void UnityBackgroundDownloadStart(IntPtr www, string full_path) { BackgroundDownloadConfig config = new BackgroundDownloadConfig(); config.url = www.uri; config.filePath = full_path; var dl = new BackgroundDownloadEditor(www, config); try { _dwnloads.Remove(full_path); } catch (Exception) { } _dwnloads.Add(full_path, www); if (!full_path.Contains(Application.persistentDataPath)) { full_path = System.IO.Path.Combine(Application.persistentDataPath, full_path); } _status = BackgroundDownloadStatus.Downloading; await www.SendWebRequest(); // _status = www.isDone ? BackgroundDownloadStatus.Done : www.isHttpError? BackgroundDownloadStatus.Failed : BackgroundDownloadStatus.Downloading; // _dwnloads.Remove(full_path); /* * BinaryWriter writer = new BinaryWriter(File.OpenWrite(full_path)); * writer.Write(www.downloadHandler.data, 0, www.downloadHandler.data.Length); * writer.Flush(); * writer.Close(); */ }
public static void Load() { string path = Application.streamingAssetsPath + "/Conversation.json"; string jsonString; #if UNITY_EDITOR || UNITY_STANDALONE_WIN jsonString = File.ReadAllText(path); #elif UNITY_ANDROID UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(path); www.SendWebRequest(); while (!www.isDone) { } jsonString = www.downloadHandler.text; #endif var dataList = JsonConvert.DeserializeObject <List <RootObject> >(jsonString); for (int i = 0; i < dataList.Count; i++) { dataList[i].Images[0] = dataList[i].Image_1; dataList[i].Images[1] = dataList[i].Image_2; dataList[i].Motions[0] = dataList[i].Motion_1; dataList[i].Motions[1] = dataList[i].Motion_2; dataList[i].CommentDic.Add(LanguageSystem.Language.Chinese, dataList[i].Comment_Chinese); _dataDic.Add(dataList[i].ID, dataList[i]); } }
public IEnumerator LoadCoroutineIE(string _savePath, DataboxObject _databoxObject, bool _callEvent) { string _j = ""; using (UnityEngine.Networking.UnityWebRequest _download = UnityEngine.Networking.UnityWebRequest.Get(_savePath)) { yield return(_download.SendWebRequest()); while (!_download.isDone) { #if UNITY_2020_1_OR_NEWER if (_download.result == UnityWebRequest.Result.ConnectionError) #else if (_download.isNetworkError || _download.isHttpError || !string.IsNullOrEmpty(_download.error)) #endif { break; } yield return(null); } #if UNITY_2020_1_OR_NEWER if (_download.result == UnityWebRequest.Result.ConnectionError) #else if (_download.isNetworkError || _download.isHttpError || !string.IsNullOrEmpty(_download.error)) #endif { Debug.Log(_download.error); } else { _j = _download.downloadHandler.text; } } if (!string.IsNullOrEmpty(_j)) { if (_databoxObject.serializer == DataboxObject.Serializer.FullSerializer) { DeserializeWithFullSerializer(_j, _databoxObject, _callEvent); } else { #if NET_4_6 DeserializeWithOdin(_j, _databoxObject, _callEvent); #endif } } else { // destroy this object //Destroy(this.gameObject); } }
public IEnumerator LoadLocalizedText(string fileName) { localizedText = new Dictionary <string, string>(); string filePath = Path.Combine(Application.streamingAssetsPath, fileName); string dataAsJson = ""; LocalizationData loadedData = new LocalizationData(); #if UNITY_EDITOR if (File.Exists(filePath)) { dataAsJson = File.ReadAllText(filePath); filePath = Path.Combine("jar:file://" + Application.dataPath + "!/assets/", fileName); loadedData = JsonUtility.FromJson <LocalizationData>(dataAsJson); for (int i = 0; i < loadedData.items.Length; i++) { localizedText.Add(loadedData.items[i].key, loadedData.items[i].value); } Debug.Log("Data loaded, dictionary contains: " + localizedText.Count + " entries, file name: " + filePath); } #elif UNITY_ANDROID || UNITY_IOS if (filePath.Contains("://") || filePath.Contains(":///")) { UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(filePath); yield return(www.SendWebRequest()); /* * while (!reader.isDone) * { * dataAsJson = reader.text; * }*/ dataAsJson = www.downloadHandler.text; } else { dataAsJson = System.IO.File.ReadAllText(filePath); } loadedData = JsonUtility.FromJson <LocalizationData>(dataAsJson); for (int i = 0; i < loadedData.items.Length; i++) { localizedText.Add(loadedData.items[i].key, loadedData.items[i].value); } #endif isReady = true; Debug.Log(filePath); yield return(null); }
public static IEnumerator WebRequest(System.Action <netData> callback, params object[] parameters) { netData data = new netData(); data.output = ""; data.isError = false; string uri = null; WWWForm form = new WWWForm(); foreach (var param in parameters) { try { Tuple <string, string> paramData = (Tuple <string, string>)param; if (paramData.Item1 != "target") { form.AddField(paramData.Item1, paramData.Item2); } else { uri = string.Format("{0}?{1}", Constants.LOGIN_SERVER, paramData.Item2); } } catch (InvalidCastException ex) { Debug.Log("Invalid field data type supplied, use Tuple<string, string> to pass in (field, value)"); } } if (form.data.Length > 0 & uri != null) { using (UnityEngine.Networking.UnityWebRequest req = UnityEngine.Networking.UnityWebRequest.Post(uri, form)) { yield return(req.SendWebRequest()); if (req.isNetworkError | req.isHttpError) { data.output = req.downloadHandler.text; data.isError = true; } else { data.output = req.downloadHandler.text; } } } else if (uri == null) { Misc.PrintDebugLine("WebHandler", "WebRequest", "No target location specified"); } callback(data); }
static private IEnumerator GetConfigStringFromStreamAssetsByWebRequest(Action <string> callback) { string path = Application.streamingAssetsPath + "/GameConfig.json"; UnityEngine.Networking.UnityWebRequest request = UnityEngine.Networking.UnityWebRequest.Get(path); yield return(request.SendWebRequest()); string configString = request.downloadHandler.text; callback?.Invoke(configString); }
public static IEnumerator ReadStreamingFile(string path, Action <DownloadHandler> callback) { if (!path.Contains("://")) { path = "file://" + path; } UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(path); yield return(www.SendWebRequest()); callback(www.downloadHandler); }
// ===================================== // // public - [Getter And Setter] Function // // ===================================== // // ========================================================================== // // private - [Proc] Function // // 중요 로직을 처리 // // ===================================== // protected IEnumerator CoExcutePHP(string hID, string strPHPName, string strTableName, delDBRequest OnFinishLoad = null, params StringPair[] arrParameter) { if (p_Event_DB_OnRequest_Start != null) { p_Event_DB_OnRequest_Start(strTableName, arrParameter); } int iRequestCount = 0; while (true) { #if UNITY_2017_1 UnityEngine.Networking.UnityWebRequest www = GetWWWNew(hID, strPHPName, strTableName, arrParameter); yield return(www.SendWebRequest()); bool bSuccess = www.error == null && (www.downloadHandler.text.Contains("false") == false); if (bSuccess == false) { Debug.Log("DBParser Error " + www.downloadHandler.text + " php : " + strPHPName + " TableName : " + strTableName); } #else WWW www = GetWWW(hID, strPHPName, strTableName, arrParameter); yield return(www); bool bSuccess = www.error == null && (www.text.Contains("false") == false); if (bSuccess == false) { Debug.Log("DBParser Error " + www.text + " php : " + strPHPName + " TableName : " + strTableName); } #endif // Debug.Log(strPHPName + " result : " + www.text); //Debug.Log( "DBParser Error " + www.text + " php : " + strPHPName + " TableName : " + strTableName ); if (OnFinishLoad == null) { break; } else if (OnFinishLoad(bSuccess, ++iRequestCount)) { break; } } if (p_Event_DB_OnRequest_Finish != null) { p_Event_DB_OnRequest_Finish(strTableName, arrParameter); } yield break; }
public static void Load() { string path = Application.streamingAssetsPath + "/BattleGroup.json"; string jsonString; #if UNITY_EDITOR || UNITY_STANDALONE_WIN jsonString = File.ReadAllText(path); #elif UNITY_ANDROID UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(path); www.SendWebRequest(); while (!www.isDone) { } jsonString = www.downloadHandler.text; #endif var dataList = JsonConvert.DeserializeObject <List <RootObject> >(jsonString); for (int i = 0; i < dataList.Count; i++) { if (dataList[i].Enemy_1 != 0) { dataList[i].EnemyList.Add(dataList[i].Enemy_1); } if (dataList[i].Enemy_2 != 0) { dataList[i].EnemyList.Add(dataList[i].Enemy_2); } if (dataList[i].Enemy_3 != 0) { dataList[i].EnemyList.Add(dataList[i].Enemy_3); } if (dataList[i].Enemy_4 != 0) { dataList[i].EnemyList.Add(dataList[i].Enemy_4); } if (dataList[i].Enemy_5 != 0) { dataList[i].EnemyList.Add(dataList[i].Enemy_5); } if (dataList[i].Enemy_6 != 0) { dataList[i].EnemyList.Add(dataList[i].Enemy_6); } _dataDic.Add(dataList[i].ID, dataList[i]); } }
public IEnumerator LoadSetupCloseBackButtons() { if (YUR.Yur.YURAssetBundle == null) { string URI = "file:///" + Application.dataPath + "/AssetBundles/" + YUR.Yur.assetBundleName; UnityEngine.Networking.UnityWebRequest request = UnityEngine.Networking.UnityWebRequestAssetBundle.GetAssetBundle(URI, 0); yield return(request.SendWebRequest()); if (request.error != null) { yield break; } else { YUR_Log.Log("Local asset bundle found!"); yield return(YUR.Yur.YURAssetBundle = DownloadHandlerAssetBundle.GetContent(request)); } } var temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("YUR Back Button"); yield return(BackButton = Instantiate(temppp, gameObject.transform)); // BackButton = (GameObject)Instantiate(Resources.Load("YUR Back Button"), gameObject.transform); BackButton.GetComponent <Button>().onClick.AddListener(delegate { if (BackButtonPressed != null) { BackButtonPressed.Invoke(); } YURScreenCoordinator.ScreenCoordinator.BackButtonPressed(); }); temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("YUR Close Button"); yield return(CloseButton = Instantiate(temppp, gameObject.transform)); // CloseButton = (GameObject)Instantiate(Resources.Load("YUR Close Button"), gameObject.transform); CloseButton.GetComponent <Button>().onClick.AddListener(delegate { if (CloseButtonPressed != null) { CloseButtonPressed.Invoke(); } YURScreenCoordinator.ScreenCoordinator.CloseButtonPressed(); }); if (Finished != null) { Finished.Invoke(); } }
IEnumerator InstantiateObject() { string uri = "https://s3-ap-southeast-1.amazonaws.com/vaanarsena/parasu-ar"; UnityEngine.Networking.UnityWebRequest request = UnityEngine.Networking.UnityWebRequestAssetBundle.GetAssetBundle(uri); yield return(request.SendWebRequest()); AssetBundle myLoadedAssetBundle = DownloadHandlerAssetBundle.GetContent(request); var prefab = myLoadedAssetBundle.LoadAsset("parasu-ar"); GameObject parasuRam = Instantiate(prefab, parentGO.transform) as GameObject; //ganesh.transform.parent = parentGO.transform; }
private IEnumerator _setQRCodeImage(string qrCodeLocation) { UnityEngine.Networking.UnityWebRequest request = UnityEngine.Networking.UnityWebRequestTexture.GetTexture(qrCodeLocation); yield return(request.SendWebRequest()); if (request.isNetworkError || request.isHttpError) { Debug.Log(request.error); yield return(null); } _qrCodeRawImage.texture = ((UnityEngine.Networking.DownloadHandlerTexture)request.downloadHandler).texture; }
static int QPYX_SendWebRequest_YXQP(IntPtr L_YXQP) { try { ToLua.CheckArgsCount(L_YXQP, 1); UnityEngine.Networking.UnityWebRequest QPYX_obj_YXQP = (UnityEngine.Networking.UnityWebRequest)ToLua.CheckObject <UnityEngine.Networking.UnityWebRequest>(L_YXQP, 1); UnityEngine.Networking.UnityWebRequestAsyncOperation QPYX_o_YXQP = QPYX_obj_YXQP.SendWebRequest(); ToLua.PushObject(L_YXQP, QPYX_o_YXQP); return(1); } catch (Exception e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP)); } }