LogoUI + <CheckServer> c__Iterator2.MoveNext()(Unity)

我现在正在开发Unity项目,并将桌面应用程序转换为Android。 我遇到一个错误:

NullReferenceException:未将对象引用设置为LitJson.JsonMapper.ToObject [ServerListJson](System.String json)中的对象的实例在UnityEngine中,在LogoUI中为0 [0],c__Iterator2.MoveNext()[0x00000]为0。 SetupCoroutine.InvokeMoveNext(IEnumerator枚举器,IntPtr returnValueAddress)[0x00000] in:0

所以我怀疑上面的错误只在LogoUI.cs中。 我是否调用JSON代码错误? 有人能指出我在做什么错吗?

LogoUI.cs

void TryShowIntro() { StartCoroutine("CheckVersion"); } IEnumerator CheckVersion() { lbl_notification.text = NOTIFICATION[0]; yield return new WaitUntil(() => tzGlobal.Instance.VERSION != null); FadeInVersion(tzGlobal.Instance.VERSION); StartCoroutine("CheckServer"); } IEnumerator CheckServer() { lbl_notification.text = NOTIFICATION[1]; // Load the URL. CheckJSonManager.Instance._AwsDatacenterURL.SetURL(); // Download the notice. WWW www = new WWW(CheckJSonManager.Instance._AwsDatacenterURL.NOTICE_URL); yield return www; // Save notice. StreetUtility.SaveJson_mk2(www.text, string.Format("{0}/notice.json", Application.streamingAssetsPath)); // Download server list. www = new WWW(CheckJSonManager.Instance._AwsDatacenterURL.SERVERLIST_URL); yield return www; // Store server list. CheckJSonManager.Instance._ServerListJSon = LitJson.JsonMapper.ToObject<ServerListJson>(www.text); // Server information to be connected is stored separately. bool bFound = false; ServerListJson pServerListJSon = CheckJSonManager.Instance._ServerListJSon; int target_server_no = System.Int32.Parse(tzGlobal.Instance.VERSION.Split('.')[2]); for (int i = 0; i < pServerListJSon.serverData.Length; i++) { if (target_server_no == pServerListJSon.serverData[i].serverNo) { bFound = true; ServerData pServerList = pServerListJSon.serverData[i]; NetworkManager.Instance.WebSocketServer.SESSION_NAME = pServerList.serverNo.ToString(); NetworkManager.Instance.WebSocketServer.SESSION_IP = pServerList.serverIP; NetworkManager.Instance.WebSocketServer.SESSION_PORT = pServerList.serverPort; tzGlobal.Instance.LOGIN_URL = pServerList.publisherURL; tzGlobal.Instance.JOIN_URL = pServerList.joinURL; tzGlobal.Instance.STREAMING_URL = pServerList.streamingURL; break; } } if (!bFound) { // Debug.LogWarning("ServerList_mk2.json does not find the required server number. Use the first server information."); Debug.LogWarning("pc_version / ph / check / serverList.json does not find the required server number. Use the first server information."); ServerData pServerList = pServerListJSon.serverData[0]; NetworkManager.Instance.WebSocketServer.SESSION_NAME = pServerList.serverNo.ToString(); NetworkManager.Instance.WebSocketServer.SESSION_IP = pServerList.serverIP; NetworkManager.Instance.WebSocketServer.SESSION_PORT = pServerList.serverPort; tzGlobal.Instance.LOGIN_URL = pServerList.publisherURL; tzGlobal.Instance.JOIN_URL = pServerList.joinURL; tzGlobal.Instance.STREAMING_URL = pServerList.streamingURL; } // Auto-connect after a while. StartCoroutine("GoToLoginSceneAutomatically"); EnableSkip("auto"); } 

我到目前为止尝试的是这个。

1.)我打印出来。

  • Debug.Log(“www notice url =”+ CheckJsonManager.Instance._AwsDatacenterURL.NOTICE_URL);

产量

jar子:文件:///data/app/com.steet383.rh.google-1/base.apk /assets/notice.json

  • Debug.Log(“www serverlist url =”+ CheckJSonManager.Instance._AwsDatacenterURL.SERVERLIST_URL);

产量

jar子:文件:///data/app/com.steet383.rh.google-1/base.apk /assets/serverList.json

现在这行代码

 // Save the server list. 

CheckJSonManager.Instance._ServerListJSon = LitJson.JsonMapper.ToObject(www.text);

有我猜这个错误,因为我把它下面的debug.log()所以它不会返回我的debug.log()

NullReferenceException:未将对象引用设置为LitJson.JsonMapper.ToObject [ServerListJson](System.String json)中的对象的实例在UnityEngine中,在LogoUI中为0,在cUI位置为0,在UnityEngine中为c_Iterator2.MoveNext()[0x00000]。 SetupCoroutine.InvokeMoveNext(IEnumerator枚举器,IntPtr returnValueAddress)[0x00000] in:0

它适用于UNITY_STANDALONE,但是当我试图将平台更改为UNITY_ANDROID时,这一行给了我错误。 这是代码

CheckJSonManager.Instance._ServerListJSon = LitJson.JsonMapper.ToObject<ServerListJson>(www.text);

不适合android?