Inherits CustomYieldInstruction.
|
static void | ClearCache (bool ancestor=false) |
| Delete the cache folder contains all cache files if cacheable. More...
|
|
static void | DeleteCache (WwwOption option) |
| Delete the cache file by corresponding URL or WwwOption if cacheable. More...
|
|
static FileInfo | RetrieveCache (WwwOption option) |
| Retrieve the cache file by corresponding URL or WwwOption if cacheable. More...
|
|
static WwwLoader | Post (WwwOption option, Action< WwwLoader > handler=null) |
| Post data to specified URL or WwwOption . More...
|
|
static WwwLoader | LoadBytes (WwwOption option, Action< WwwLoader, byte[]> handler) |
| Load bytes data from specified URL or WwwOption . More...
|
|
static WwwLoader | LoadText (WwwOption option, Action< WwwLoader, string > handler) |
| Load a text data from specified URL or WwwOption . More...
|
|
static WwwLoader | LoadAsset (WwwOption option, Action< WwwLoader, AssetBundle > handler, bool unload=true) |
| Load an UnityEngine.AssetBundle from specified URL or WwwOption . More...
|
|
static WwwLoader | LoadAudio (WwwOption option, Action< WwwLoader, AudioClip > handler) |
| Load an UnityEngine.AudioClip from specified URL or WwwOption . More...
|
|
static WwwLoader | LoadImage (WwwOption option, Texture2D texture, Action< WwwLoader, Texture2D > handler=null) |
| Load a UnityEngine.Texture2D from specified URL or WwwOption . More...
|
|
static WwwLoader | LoadMovie (WwwOption option, Action< WwwLoader, MovieTexture > handler) |
| Load a UnityEngine.MovieTexture from specified URL or WwwOption . More...
|
|
|
static bool | isCacheable [get] |
| Determine if is cache supported, i.e., the platform is not WebGL. More...
|
|
static string | cacheFolder [get, set] |
| The folder to save cache files. More...
|
|
string | url [get] |
| The full URL passed to UnityEngine.WWW . More...
|
|
string | info [get] |
| The info describes the used URL or WwwOption . More...
|
|
DateTime | time [get] |
| The time when loading started. More...
|
|
float | duration [get] |
| The duration whole process cost in seconds, set when done. More...
|
|
float | progress [get] |
| The progress of UnityEngine.WWW , between 0~1. More...
|
|
string | error [get] |
| The error message of UnityEngine.WWW or loading canceled. More...
|
|
bool | isDone [get] |
| Flag if loading process done. More...
|
|
Basically a wrapper of UnityEngine.WWW
for work easier.
Provide simple API to implement Fire'n'Forget by callback when loading process done. This invokes the handler even process failed, check WwwLoader.error
before using loaded data in case. The instance returned by the loading methods is the same as the one passed to the callback for convenience. This derives from UnityEngine.CustomYieldInstruction
that you can yield return it in a coroutine in case.
This can cache loaded data to local file system, but situations below is not cacheable:
- Web player or WebGL, not supported to save local file.
- When posting bytes data to a web server, needless in common and hard to track.
- When loading a local file, needless since the cache is also local.
An example to load image into an existed UnityEngine.Texture2D
below:
WwwLoader.LoadImage(
"http://some.where/photo.png",
GetComponent<Renderer>().material.mainTexture as Texture2D
);
Or to load a local JSON file to setup your class:
WwwLoader.LoadText(
"../folder/doc.json",
(loader, text) => { if(null == loader.error) doc = JsonConvert.DeserializeObject<Doc>(text); }
);