How to resolve that? I receive this at 2:10 instead-> NullReferenceException: Object reference not set to an instance of an object GetMethod+d__3.MoveNext () (at Assets/GetMethod.cs:21) UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at :0) UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) GetMethod:GetData() (at Assets/GetMethod.cs:17) UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)
How do you actually POST it though? I'm trying to upload a file to my web hosting, I can retrieve it and display it using the GET method but the POST method doesn't work, just says forbidden if I define the directory only where my handle_post.php file is, or if I specify the actual php file, it says error 404. I'm confused. Any help would be deeply appreciated.
Sry for asking a question , I was following ur steps (PostData) and then Unity returns my start not set to an instance of an object (All codes are correct ) What is goning on here ? :(
I have to see your code to find the exact reason but if the error is in Start then my guess is that the gameobject with the given name is not found in the scene. Check if the name is exactly the same.
Hi Unity3D School, I am new to Unity and have not much knowledge about webserver, my case is: I have a LAMP set up in my Raspberry Pi 4, and it working fine. I can open phpmyadmin page on Raspi on my PC's browser. I need to make an very simple mobile app to trade data with Raspi for Home management usage. Does the method mentioned in this work with my config? If not, please tell me what I need to do, or just change the concept. Please help.
@@Unity3DSchool Thanks, I tried that post button, it sends 4 as the data, but where I can change it and where it will be showing? since the URL inside the code is the 'get' function URL?
@@luyangzou6479 You can send a POST request to the same URL and the server will process it differently. If you run a GET request and see there are 4 items, then you run a POST to the same URL and it's set up to handle them, you should be able to run the GET request a second time and see 5 items.
It works for me. Its shows me the JSON Data but i just want to show a specific part of the API and not all information. Can you share how to do JsonUtility.FromJson(json) after Web request. Thank you.
Yes. You can covert image into either binary or base64 string. After that you can send the binary/string with POST body. Never tried it but it should work. Will make a video on it. 😁
hello :) this method really good and works good for me but in my case I am using unity3d and azure ,,, so I want the text to appear in TextMeshPro component which I add to SlateUGUI ,,, so i just i dont know how to modify the script with that cause i tryed but doesnt work ..i hope you can help me
Replace InputField with TextMeshPro. If it is still not working then I suggest you to search online "setting text of TextMeshPro in Unity" or something like this. You will surely find the solution.
@@Unity3DSchool It works well for me now thank you, just one question please... I have different texts which I put it in Json file and put it on server ,,, and i want to get them like here in this video, how can I modify the Script ? if I want to add 2 buttons next and previous to pass from text to other how can i add them to script ? really hope you can help me with that cause it s important for me and thank you so much :)
This video is not about getting game object. I am just using one of the methods available to get the game object. Also think about it, if searching is so bad then why its still available to use. If I can not use searching here then where can I use it? think about it. Just don't use Find in every frame and you are good to go. docs.unity3d.com/ScriptReference/GameObject.Find.html
@@Unity3DSchool The reason searching is so bad is that if you are searching by name and you change the name of the gameobject then you could easily get a null reference. The reason I pointed this out is that beginners pick up a lot of programming habits from tutorials. So even if the video is not about getting gameobjects, someone could learn the wrong or inefficient method. Not only are you using Gameobject.Find(), you are also getting component when you could simply just assign it and still make it private.
The point is that you will get NRE if you change the name. No matter what method you use, there will always be 'what if..'. What If someone deletes the game object OR what if I delete the component OR What if I delete the tag etc. There is no bad code, only bad use. In this particular case, I found this the quickest way to do things, and at the same time, I demonstrated the use of Find. As for beginners, I will encourage them to learn about the Find, how to use it and why it should be used carefully. But thanks for mentioning this. I will try to be more careful in the future.
I didnt realise you could do this sort of stuff.
When I found out years ago, it blew my mind with the amount of integration you can perform.
Action speaks louder than words. Cool~
"Are you reviewing headsets or cows" Type video music😂
How to resolve that? I receive this at 2:10 instead->
NullReferenceException: Object reference not set to an instance of an object
GetMethod+d__3.MoveNext () (at Assets/GetMethod.cs:21)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at :0)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
GetMethod:GetData() (at Assets/GetMethod.cs:17)
UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)
Facing same issue. Have you solved it?
Anyone knows of a tutorial of how to do it the other way around? i have and application which has to post information into unity using rest
How do you actually POST it though? I'm trying to upload a file to my web hosting, I can retrieve it and display it using the GET method but the POST method doesn't work, just says forbidden if I define the directory only where my handle_post.php file is, or if I specify the actual php file, it says error 404. I'm confused. Any help would be deeply appreciated.
Thank u so much..excellent video 😍😍🤩🤩🤩
How can we send the secret and public keys for security connection?
No matters, How much subscribers.... This Video Matters which is very Easy to understand and start me with Rest API. Thanks bro :) ☺
But How to access data which I got in JSON?, kindly make video on this too.
I will surely create a video on this topic. Meanwhile you can check this video for JSON Deserialization - ruclips.net/video/g0k4XStzkLQ/видео.html
Sry for asking a question , I was following ur steps (PostData) and then Unity returns my start not set to an instance of an object (All codes are correct ) What is goning on here ? :(
I have to see your code to find the exact reason but if the error is in Start then my guess is that the gameobject with the given name is not found in the scene. Check if the name is exactly the same.
do you know what kind of service that I can manage my own json for free or cheap?
I got this error while get data - HTTP/1.1 405 Method Not Allowed
Hi Unity3D School,
I am new to Unity and have not much knowledge about webserver, my case is:
I have a LAMP set up in my Raspberry Pi 4, and it working fine. I can open phpmyadmin page on Raspi on my PC's browser.
I need to make an very simple mobile app to trade data with Raspi for Home management usage. Does the method mentioned in this work with my config?
If not, please tell me what I need to do, or just change the concept.
Please help.
yes, since this is a http request.
How can I GET request all the text from the box, basically the reverse of what you did in the video.
JsonConvert.SerializeObject
how to check the post data is working ?
isHttpError or isNetworkError will return true in case there is problem in posting data.
@@Unity3DSchool Thanks, I tried that post button, it sends 4 as the data, but where I can change it and where it will be showing? since the URL inside the code is the 'get' function URL?
@@luyangzou6479 You can send a POST request to the same URL and the server will process it differently. If you run a GET request and see there are 4 items, then you run a POST to the same URL and it's set up to handle them, you should be able to run the GET request a second time and see 5 items.
It works for me. Its shows me the JSON Data but i just want to show a specific part of the API and not all information. Can you share how to do JsonUtility.FromJson(json) after Web request. Thank you.
Can you use a POST to upload an image file?
Yes. You can covert image into either binary or base64 string. After that you can send the binary/string with POST body. Never tried it but it should work. Will make a video on it. 😁
@@Unity3DSchool And a zip file is the same?
Hi, what if the json data is nested, for example:
{
"user": {
"userID": "1234",
"username": "testuser",
}
}
write a class which has that format and deserialize from JSON into this class, the class has to be [System.Serializable]
So can we play a unity project with the same way mate?
How to get my own weblink
Hey how could I use web request to get texture?
hello :) this method really good and works good for me but in my case I am using unity3d and azure ,,, so I want the text to appear in TextMeshPro component which I add to SlateUGUI ,,, so i just i dont know how to modify the script with that cause i tryed but doesnt work ..i hope you can help me
Replace InputField with TextMeshPro. If it is still not working then I suggest you to search online "setting text of TextMeshPro in Unity" or something like this. You will surely find the solution.
@@Unity3DSchool It works well for me now thank you, just one question please... I have different texts which I put it in Json file and put it on server ,,, and i want to get them like here in this video, how can I modify the Script ? if I want to add 2 buttons next and previous to pass from text to other how can i add them to script ? really hope you can help me with that cause it s important for me and thank you so much :)
Its only work if we use your web
Thanks for this useful tutorial, you've helped me so much!
hi , how to post data in webserver
Posting data is also demonstrated in video.
Very good, thanks.
Thank you soo much man
thanks man
Thank you
muchas gracias!
Your code is so bad! why are you searching for gameobjects by their name when you can serialize it and still make it private? SMH
This video is not about getting game object. I am just using one of the methods available to get the game object. Also think about it, if searching is so bad then why its still available to use. If I can not use searching here then where can I use it? think about it.
Just don't use Find in every frame and you are good to go.
docs.unity3d.com/ScriptReference/GameObject.Find.html
@@Unity3DSchool The reason searching is so bad is that if you are searching by name and you change the name of the gameobject then you could easily get a null reference. The reason I pointed this out is that beginners pick up a lot of programming habits from tutorials. So even if the video is not about getting gameobjects, someone could learn the wrong or inefficient method. Not only are you using Gameobject.Find(), you are also getting component when you could simply just assign it and still make it private.
The point is that you will get NRE if you change the name. No matter what method you use, there will always be 'what if..'.
What If someone deletes the game object OR what if I delete the component OR What if I delete the tag etc.
There is no bad code, only bad use. In this particular case, I found this the quickest way to do things, and at the same time, I demonstrated the use of Find.
As for beginners, I will encourage them to learn about the Find, how to use it and why it should be used carefully.
But thanks for mentioning this. I will try to be more careful in the future.
Thank you so much
You might be good with networking but a very bad Unity programmer XD