- Home /
Question by
Elaiya · Sep 20, 2017 at 08:15 AM ·
unity 5build-errorandroid build
Instantiate not working on android build but it works on Unity player..My Question is there any problem with unityweb request..?
using System.Collections; using System.Collections.Generic; using UnityEngine; using System; using UnityEngine.Networking; public class NEWunitycall : MonoBehaviour {
// Use this for initialization
public static double TEST1;
public static double TEST2i;
bool hit;
void Start () {
StartCoroutine (LoadLoginInfo ());
}
// Update is called once per frame
IEnumerator LoadLoginInfo ()
{
string blue=(requestlatlong.ToString());
byte[] rawData =System.Text.Encoding.UTF8.GetBytes(blue);
string url = "http://192.002.2.652:1900/api/v1/user/objectlist";
var www = new UnityWebRequest(url, "POST");
www.SetRequestHeader("Content-Type", "application/json");
www.SetRequestHeader("fbid", "997423570990");
www.uploadHandler = (UploadHandler) new UploadHandlerRaw(rawData);
www.uploadHandler.contentType= "application/json";
www.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer();
yield return www.Send();
if (www.isNetworkError) {
Debug.Log (www.error);
} else {
Debug.Log ("Data: " + www.downloadHandler.text);
GameObject clone = Instantiate ((Resources.Load<GameObject>("prefab/C1")), transform.position = new Vector3 (0.07f, 1.44f, 10.49f), Quaternion.identity) as GameObject;
clone.transform.SetParent (GameObject.FindGameObjectWithTag ("MainCamera").transform);
Debug.Log ("second");
Debug.Log("Load Login Info");
hit=true;
}
}
}
Comment
you've got a Debug.Log for both cases of the www request. Where are you getting at?
Else block.,the service is working fine but the object is not displaying on android build
The code should work without the www request since it's not used for the spawn. Run the spawn on Android and try to get it to work. Use a console window where you run adb logcat -s Unity
to see what the game is doing. You could also configure the game view to match the android device aspect and resolution to see if it them still is visible.