日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

ios中while()和 android中的不同之处

發(fā)布時(shí)間:2025/3/17 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ios中while()和 android中的不同之处 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

?

ios中while()不能www方式讀取文件

void FDJson() {using(WWW _load = new WWW("file://"+FileFunc.GetStreamPathRW("FontPreferenceC.json"))) // {while(!_load.isDone){}
  }
}

安卓卻可以這樣讀取

?

經(jīng)過(guò)修改

IEnumerator FDJson() {using(WWW _load = new WWW("file://"+FileFunc.GetStreamPathRW("FontPreferenceC.json"))) // {while(!_load.isDone){yield return null;} } }

?

可以在ios下正常讀取了

?

?

但是這個(gè)要用到IEnumerator 枚舉器,很不方便,所以讀取文件最好用system.io接口讀取

public static string ReadTextFromFile (string path){if (System.IO.File.Exists (path)){return System.IO.File.ReadAllText (path, System.Text.Encoding.UTF8);}else return null;}

?

但io在安卓中不適用,因?yàn)榘沧康奈募际莏ar壓縮格式,所以在安卓中要用www讀取文件,

http://answers.unity3d.com/questions/210909/android-streamingassets-file-access.html

So I was never able to figure out if it is possible to use the System.IO.FileInfo class to check the existence of a file that is added to your Android .APK file through the?StreamingAssets?directory. At this point I really doubt it's possible at all. The reason for this is that the .APK file is an archive, as you may know you can open a .APK file using any archiving utility (WinRAR for example) to inspect it's contents as I touched on above. So the FileInfo class apparently does not support archives like this.

Fortunately the WWW class does support a URI in the style of a?JAR URL. So instead I am just pointing my WWW object at the location where the file might be (using the correct JAR URL syntax) and seeing if I come back with an error.

This forums post?was extremely insightful in showing how exactly to open a file from the?StreamingAssets?folder. I'm kind of surprised that this issue isn't better documented, but hopefully in the future this post will save someone a lot of time.

In review:

  • Don't use System.IO.FileInfo to access files that are archived in your .APK
  • WWW is your best friend.
  • The correct URI to access?StreamingAssets?on Android devices is:?"jar:file://" + Application.dataPath + "!/assets/" + fileName
  • ?

    ?

    轉(zhuǎn)載于:https://www.cnblogs.com/pengyingh/archive/2013/04/18/3029727.html

    總結(jié)

    以上是生活随笔為你收集整理的ios中while()和 android中的不同之处的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

    如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。