Unity3d save a dynamically downloaded file

Source: Internet
Author: User

I am also a novice, previously exposed to dynamic loading resources, but this is in memory or the program's own cache, inconvenient to use

I just tried, can I put it on the disk, the result is yes, TXT and FBX in the test after downloading from the server after the data is correct

On the code:

IEnumerator downasfile (string path,string filename) {
Experiments have shown that this is possible, to save the file on the server to the local
www www = new www (path);
yield return www;
if (www.error==null) {
Debug.Log ("Download Complete");
Byte[] stream = www.bytes;
FileStream fs = new FileStream (filename, filemode.createnew);
Create the writer for data.
BinaryWriter w = new BinaryWriter (FS);
Write data to Test.data.
W.write (stream);
W.close ();
Fs. Close ();
}
}

That's it, Meow ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.