Пример #1
0
    public void saveinven()                                                          //인벤토리정보 저장함수
    {
        saveinventory save = new saveinventory();                                    //인벤토리저장할 변수에 해당클래스 할당

        save.inventoryList = inventoryItemList;                                      //인벤토리 저장
        string json = JsonUtility.ToJson(save);                                      //제이슨에 인벤토리 정보 저장

        File.WriteAllText(Application.persistentDataPath + "/invendata.json", json); //인벤데이타텍스트 생성
    }
Пример #2
0
 public void loadinven()//인벤토리 정보를 불러올함수
 {
     try
     {
         string        json = File.ReadAllText(Application.persistentDataPath + "/invendata.json"); //인벤데이터텍스트 읽어옴
         saveinventory load = new saveinventory();                                                  //로드에 해당클래스 할당
         load = JsonUtility.FromJson <saveinventory>(json);                                         //로드에 인벤데이타 저장
         for (int i = 0; i < load.inventoryList.Count; i++)                                         //인벤토리 아이콘과 스트라이트 불러오기
         {
             load.inventoryList[i].itemIcon = Resources.Load("itemIcon/" + load.inventoryList[i].itemID.ToString(), typeof(Sprite)) as Sprite;
         }
         inventoryItemList = load.inventoryList;//인벤토리에 인벤토리 정보 저장
     }
     catch { }
 }