void CreateJson_MonsterCollection(){
counter = 0;
foreach(Monsters m in PlayerMonsterCollection){
Monsters _mon = new Monsters();
MonsterDetails scp = MonsterData[counter].GetComponent();
scp.displayName.text = m.name;
scp.displayHp.text = m.health.ToString();
scp.displayLvl.text = m.level.ToString();
scp.displayRarity.text = m.rarity;
scp.Icon.sprite = m.image;
scp.displayType.text = m.type;
string _MonsterData = JsonMapper.ToJson(_mon);
Debug.Log(_MonsterData);
counter++;
}
}
broken ;@ … returns defaults(“Null”) not MonsterDetails values no errors…
{“unlocked”:false,“name”:null,“health”:0,“level”:0,“type”:null,“rarity”:null,“image”:null,“monster”:null}
MV10
4
Using code-tags makes your code more readable.
There isn’t enough information here for anyone to help you.
If the JsonMapper returns null, the only two relevant lines of code are:
Monsters _mon = new Monsters();
string _MonsterData = JsonMapper.ToJson(_mon);
You create this _mon object, then don’t do anything with it except feed it to this ToJson method.
- What happens in the Monsters constructor?
- What is JsonMapper? It isn’t part of Unity.
1 Like