Esempio n. 1
0
    private void updateinitialization()
    {
        initialization initialization = new initialization();

        initialization.isDone = 1;
        //將myPlayer轉換成json格式的字串
        string saveString = JsonUtility.ToJson(initialization);

        //將字串saveString存到硬碟中
        System.IO.StreamWriter file = new StreamWriter(System.IO.Path.Combine(Application.streamingAssetsPath, "initialization"));
        file.Write(saveString);
        file.Close();
    }
Esempio n. 2
0
    public void load()
    {
        string loadJson;
        //讀取json檔案並轉存成文字格式
        string       filePath = System.IO.Path.Combine(Application.streamingAssetsPath, "initialization");
        StreamReader file     = new StreamReader(filePath);

        loadJson = file.ReadToEnd();
        file.Close();


        //新增一個物件類型為playerState的變數 loadData
        initialization loadData = new initialization();

        //使用JsonUtillty的FromJson方法將存文字轉成Json
        loadData = JsonUtility.FromJson <initialization>(loadJson);

        //驗證用,將sammaru的位置變更為json內紀錄的位置
        isDone = loadData.isDone;
    }