Hello,
I’m new to Unity and C#. I’m familiar with programming, but C# is foreign to me. I plan on going through the proper steps to learn it, but was wondering if I could ask for help with a basic http request in the meantime. I have searched this out and spent way too many hours on this with not much to show.
I have succeeded in getting an event handler to respond to button presses on the UI I’ve created. My setup so far is as follows:
Hierarchy:
-Main Camera
-Canvas
-----Button
---------Text
-----_Manager
-----EventSystem
_Manager is the object that handles the buttonClick script.
I have a script called buttonClick.cs that contains the following code:
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
public class buttonClick : MonoBehaviour {
public void react () {
Application.LoadLevel (Application.loadedLevel);
Debug.Log ("Pressed!");
}
}
All of this works well. The next, and really the last thing I need to do, is make a simple http GET request to my server, we’ll call it mysite.com. I have my server setup to return a short, one word string. I want to store this in a variable for reference, lets say myVar.
Can what I want to do be build into my react () function? If it needs to be restructured, can someone show me a solution in this scenario?
Thank your very much for taking the time to look at this.