Hello,
I am using a Photon from Particle.Io and I would like to be able to make it communicate with my Unity scene. I have started by using a JSON Parser (the Script is called SimpleJSON) and a Unity Photon library in C# (the Script is called PlayerController).
In the library there is a function called “GetVariableRaw”
public int GetVariableRaw(string varName)
{
HttpWebRequest request = GetHttpWebRequest(webMethod.GET, String.Format(addrCoreAPIGetVariable, this.CoreID, varName, AccessToken), string.Empty);
object jsonObj = GetHttpWebResponseAsJSONData(request, typeof(ResponseVar));
var jsonResponse = JSON.Parse(jsonObj.ToString());
return jsonResponse[“result”].AsInt;
}
It is used by my code like this:
light_lux = core.GetVariableRaw(“analogvalue”);
to read the variable “analogvalue” on the Particle cloud, which is the output of a photoresistor connected to my Photon.
Since this works I am now looking for a way to POST a variable on the Photon. I believe the function might be already there in the piece of code I am using but I am not sure… What should the command look like? I am using the simple tutorial where the Photon is hooked up to a LED and to Photoresistor. I would like to be able to switch on/off the LED from my Unity3D scene.
Does anyone managed to successfuly make a Particle Photon and Unity communicate together?
Thanks a lot.