1. 程式人生 > >unity實現安卓手機讀xml方法

unity實現安卓手機讀xml方法

直接上程式碼

        string path = string.Empty;
        WWW www;
        if (Application.platform == RuntimePlatform.Android) {
            path = Application.streamingAssetsPath + "/AppInfo.xml"; 
        } else {
            path = "file://" + Application.streamingAssetsPath + "/AppInfo.xml";
        }

        www = new WWW(path);
        yield return www;

        XDocument xDoc = XDocument.Parse(www.text);
        XElement root = xDoc.Root;