STDIO Developer

20 bundles
1 file2 months ago
1

Lưu Trữ Dữ Liệu Trong Android Với Unity

1234567891011121314151617181920212223242526using System.Collections;
using UnityEngine;

public class ReadDataStreaming : MonoBehaviour
{
    string dataString;
    void Start () {
        StartCoroutine(ReadDataStreamingAssets("gamesetting.json"));
        print(dataString);
    }

    IEnumerator ReadDataStreamingAssets(string fileName)
    {
        string streamingPath = System.IO.Path.Combine(Application.streamingAssetsPath, fileName);
        if (streamingPath.Contains("://"))
        {
            WWW www = new WWW(streamingPath);
            yield return www;
            dataString = www.text;
        }
        else
        {
            dataString = System.IO.File.ReadAllText(streamingPath);
        }
    }
}