Example #1
0
    protected void Read(Type t)
    {
        string filePath = Path.Combine(Application.persistentDataPath, file_path);

        Debug.Log(filePath);
        if (!File.Exists(filePath))
        {
            FileOperate.FileCreate(filePath);
        }
        string content = FileOperate.ReadFile(filePath);

        if (string.IsNullOrEmpty(content))
        {
            data = t.Assembly.CreateInstance(t.ToString()) as BaseData;
        }
        else
        {
            data = JsonUtility.FromJson(content, t) as BaseData;
        }
    }