class1 calling class2, no value?
Since CreateFromJSON need a class without Monobehaviour, I have 2 classes in my GO:
[System.Serializable]
public class nomre
{
public static int age;
public static nomre CreateFromJSON(string jsonString)
{
return JsonUtility.FromJson<nomre>(jsonString);
}}
and below
public class caller : MonoBehaviour {
...
string jsonity = www.downloadHandler.text;
Debug.Log("www." + jsonity);
nomre.CreateFromJSON(jsonity);
Debug.Log("age: " + nomre.age);
The debug(www) shows that the JSON object is correct and includes "age" : 20 but the debug(nomre.age) shows 0. There's no warning or error in my code, I just don't get it. Thanks for your help guru!
Comment
@Lord_Ford? I tried your reply http://answers.unity3d.com/questions/1033911/call-a-class-with-in-other-class.html without luck.
Best Answer
Answer by philmzo · Nov 21, 2016 at 10:07 AM
JsonUtility.FromJsonOverwrite(jsonString, this); works from within the Monobehaviour class. No need for another funky class.