zoukankan      html  css  js  c++  java
  • Unity 网络请求(1)


    using UnityEngine;
    using System.Collections;
    
    public class Scene1 : MonoBehaviour {
    	
    	//下载图片的容器
    	private Texture texture1;
    	
    	IEnumerator loadNetWork()
    	{
    		if(texture1 == null)
    		{
    			//网络请求路径
    			WWW data = new WWW("http://ww1.sinaimg.cn/bmiddle/61e61e8cjw1e6m3iaag6nj20fk0bc0ul.jpg");
    			//等待下载完成
    			yield return data;
    			//得到下载的图片
    			texture1 = data.texture;
    		}
    		//将下载的图片显示的物体上
    		renderer.material.mainTexture = texture1;
    	}
    	
    	void OnGUI()
    	{
    		//点击Button开始下载
    		if(GUILayout.Button("NETDowload"))
    		{
    			StartCoroutine(loadNetWork());
    		}
    	}
    	
    	// Use this for initialization
    	void Start () {
    	
    	}
    	
    	// Update is called once per frame
    	void Update () {
    	
    	}
    }
    


  • 相关阅读:
    动态数组arraylist的使用
    第一次
    layui.mobile.css
    index.html
    Ansible部署配置
    微服务项目配置文件
    镜像挂载
    网卡设置
    获取内存信息
    超时方法
  • 原文地址:https://www.cnblogs.com/snake-hand/p/3190111.html
Copyright © 2011-2022 走看看