I’m looking for a way to get more than one variable from a page that’s located in my server.
At the moment the page has this text:
Critical Chance: 20
Enemy Health Min: 20
Enemy Health Max: 100
Gold Drop Min: 10
Gold Drop Max: 200
Random Chance Gold Multiplier: 10
Gold Multiplier Min: 2
Gold Multiplier Max: 5
I want to get certain numbers from that page and use it in my C# script for certain variables. I understand I could use WWW, but It grabs all the text from that page instead of each one. What’s a smarter way of doing this? ?
[Serializable]
public class MyData
{
public int Critical_Chance ;
public int Enemy_Health_Min ;
public int Enemy_Health_Max ;
public int Gold_Drop_Min ;
public int Gold_Drop_Max ;
public int Random_Chance_Gold_Multiplier ;
public int Gold_Multiplier_Min;
public int Gold_Multiplier_Max ;
}
use JsonUtility to Deserialize JSON into a Mydata Object :
//get the string from my server
string myServerResponse=getStringFromServer();
// deserialize json text into Object
MyData obj=JsonUtility.FromJson<MyData >(myServerResponse);