Unity3d Tutorial Web Server Chapter: (second) download pictures from the server

Source: Internet
Author: User

reproduced from Wind Yu Chong Unity3d Tutorial College
download pictures from a Web server

On a talk about the wind Yu Chong introduced the Wamp server and installation. This explains how to download content from the server to the Unity3d program.

To the Wamp path under the WWW folder to drag a picture, where the use of cat.jpg, input http://localhost/cat.jpg, you can see the picture below,

New Unity Project, create a sphere, create an arbitrary name material, and assign the material to a sphere. Create a script named GetImage with the following code,using Unityengine;using System.Collections; Public class Getimage:monobehaviour {void Ongui (){if (GUI. button (new Rect (0,0,100,50), "Get Image")){Startcoroutine (Getwebimage ());}}IEnumerator getwebimage (){www mywww = new www ("http://localhost/cat.jpg");yield return mywww;renderer.material.mainTexture = mywww.texture;}}

After running, click on the top left button, the white ball is given to the page image as a map, how, simple? Summary: Unity3d reads HTTP content on the core is mywww =www (URL), according to what type of content you read, if the text is Mywww.text read, is the picture mywww.texture read, is the video Mywww.movie read. It can be used or stored later.

Unity3d Tutorial Web Server Chapter: (second) download pictures from the server

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.