public void LoadMobData() { try { Debug.Log("몬스터 정보 로드 성공"); /*string jsonData = File.ReadAllText(saveOrLoad(false, false, "mobData")); * mobDataFile = JsonUtility.FromJson<mobDataFile>(jsonData);*/ mobDataFile = JsonUtility.FromJson <MobDataFile>(Resources.Load <TextAsset>("mobData").ToString()); for (int i = 0; i < mobDataFile.mobDatas.Count; i++) { //mobDataFile.mobDatas[i].sprite = loadSprite(mobDataFile.mobDatas[i].spritePath); mobDB.Add(mobDataFile.mobDatas[i]); } // 딕셔너리에 몬스터 정보 입력 for (int i = 0; i < mobDB.Count; i++) { mobDatas.Add(mobDB[i].code, mobDB[i]); } } catch (FileNotFoundException) { Debug.Log("로드 오류"); string jsonData = JsonUtility.ToJson(mobDataFile, true); File.WriteAllText(SaveOrLoad(false, false, "mobData"), jsonData); LoadMobData(); } }
// private string prefabPath = "Images/Mob"; // Start is called before the first frame update void Start() { instance = this; mobDataFile = new MobDataFile(); mobDataFile.mobDatas = new List <EntityData>(); //SaveMobData(); LoadMobData(); }