If you haven't done a lot of work with HTTP, you are probably wondering, "Why is UnityWeb needed?".
Here is a contrived, yet realistic scenario which demonstrates something you can do with UnityWeb, but is impossible with the WWW class.
Posit: Your game needs to download an avatar image for each player and use it as a texture. A player can update their avatar image, so you must periodically check to see if the image has changed.
Using the Unity3D WWW class, you might do something like this:
for each member
download avatar image
update avatar texture
If you have 50 avatars in one game, you will download 50 different images. Every 10 minutes or so, you re-download the images.
Using UnityWeb, you can do something better.
for each memberUnityWeb will only redownload a URL if it has changed since you last downloaded it. UnityWeb uses the magic of Etags to make this work. To make this type of caching happen, you simply add:
download avatar image
if image has changed, update avatar texture
request.useCache = true;This results in faster response times, less web traffic, and you could poll much quicker than every 10 minutes, as only changes will be downloaded.
1 comment:
Wow ! Super impressed.
Thanks for the MIT license.
Post a Comment