Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System;
- public class StaticData : MonoBehaviour
- {
- public static string LoadResourceTextfile(string name)
- {
- string filePath = "JsonData/" + name;
- TextAsset targetFile = Resources.Load<TextAsset>(filePath);
- return targetFile.text;
- }
- [Serializable]
- public class Planets
- {
- public List<PlayObject> list;
- }
- public Planets planets;
- public PlayObject GetPlanetByKeyName (string key_name)
- {
- foreach(var i in planets.list)
- {
- if(i.keyName == key_name)
- {
- return i;
- }
- }
- return null;
- }
- void Awake()
- {
- string json;
- DontDestroyOnLoad(this.gameObject);
- json = LoadResourceTextfile("Planets");
- json = "{\"list\":" + json + "}";
- planets = JsonUtility.FromJson<Planets>(json);
- foreach(var i in planets.list)
- {
- i.Init();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement