- Home /
loading local file synchronically using WWW?
I was wondering if the WWW can be used without yield when loading the local files?
I have tried to use it to load local file synchronically:
WWW www = new WWW( "file:///" + assetPath );
AssetBundle prefabBundle = www.assetBundle;
GameObject instance = (GameObject)Instantiate( prefabBundle.Load( prefabName ) );
It works but I am not sure whether it is due to the file size is small.
Thanks!
Answer by Paulius-Liekis · Sep 05, 2013 at 08:57 PM
while (!www.IsDone)
{
// sychnonuous wait
}
void LoadFile( string path )
{
WWW www = new WWW( "file:///" + path );
while ( !www.isDone )
{
Debug.Log(www.progress);
}
Debug.Log("Done");
}
the loop never ends if I write code like this.
Answer by fuerogames · Nov 12, 2015 at 04:32 PM
just use System.IO.File.ReadAllText
The question asked how to do that using WWW class, so your answer doesn't help. He might be tight to WWW class, because he needs to load AssetBundles.
Your answer
Follow this Question
Related Questions
How to use the file protocol with the WWW class? 1 Answer
WWW file:// protocol to list a directory 1 Answer
How to load a textAsset not from resources and add it as Script Component? 0 Answers
Using WWW to load all files in StreamingAssets directory 2 Answers
[help]How can I read the file in StreamingAssets on iPad/iPhone platform??? 0 Answers