- Home /
Duplicate Question
How to access (JSON) object from other class?
I have
void Awake(){ TextAsset targetFile = Resources.Load<TextAsset> ("Transactions") as TextAsset; TransactionCollection data = JsonUtility.FromJson<TransactionCollection> (targetFile.text); }
plus these serializable class like so: [Serializable] public class TransactionCollection { %|-1718415094_1|% } [Serializable] public class Transaction { %|-1787790427_2|% %|-1543139204_3|% public int amount; }
Right now, data.transactions[1].amount is only available within Awake() it seems... How can I make this data available in other methods or scripts? Should I make that TransactionCollection static or something?
FAQ :
There exists duplicate questions with answers if you were to do a search, either on Answers or on the Forum or on Unity's tutorials
Badly formated question: code needs to be formatted using the 101/010 button, break your post up into several parts so it's understandable what you are asking, and make sure there is a question in your post
Follow this Question
Related Questions
All Units Go to Same Waypoint 1 Answer
Best way to store and use player classes? 0 Answers
Can't get Json out of class 0 Answers