private IEnumerator GetData()
{
WWWForm form = new WWWForm();//php에 보낼 폼을 만듦
form.AddField("data", num);
UnityWebRequest request = new UnityWebRequest();
using (request =
UnityWebRequest.Post("http://localhost/LoadData.php", form))
{
yield return request.SendWebRequest();
if (request.isNetworkError)
{
Debug.Log(request.error);
}
else
{
Debug.Log(request.downloadHandler.text.Length);
Debug.Log(request.downloadHandler.text[request.downloadHandler.text.Length - 1]);
Debug.Log(request.downloadHandler.text[request.downloadHandler.text.Length - 2]);
Debug.Log(request.downloadHandler.text[request.downloadHandler.text.Length - 3]);
string str=request.downloadHandler.text;
str = str.Substring(0, str.Length - 2);
Debug.Log(str[str.Length - 1]);
results = request.downloadHandler.data;
byte[] by = Convert.FromBase64String(request.downloadHandler.text);
Debug.Log(by.Length);
Mesh mesh = MeshSerializer.ReadMesh(by);
transform.GetComponent<MeshFilter>().mesh = mesh;
}
}
I am sending a byte[] as a unity web request, but when sending and receiving, a space is added at the end. so at the beginning, I calculated this space, but it seems to be different for each character length. The base64 type seems to end with == but I don't know if this is correct If you use Unity Web Request, can you tell how many null are added? Or is there a standard for how many null are there?
---added
After sending to Unity Web Request, Post-> Download, the length of the string increased by 2, so at the beginning, only 2 deleted. As I keep using this method, I don't know what to do because each object has a different null length. Is it correct to find and compare only the last blank column?