unity, www download texture

February 13, 2013   ·   0 Comments

Screen Shot 2013-02-13 at 1.46.40 PM

Screen Shot 2013-02-13 at 1.46.40 PM

using UnityEngine;
using System.Collections;

public class WWW_Sample1 : MonoBehaviour {
	
	 
  string _FileLocation,_FileName; 
	// Use this for initialization
	/*
	void Start () {
	
      
      ////////////
      _FileLocation=Application.dataPath; 
      _FileName="SaveData.xml";

	}
	*/
	// Update is called once per frame
	/*
	void Update () {
	}
	*/
	void OnGUI(){
	/////////////
   // Loading The Player... 
   ////////////// 
     GUI.Box (new Rect(10,10,160,90), "Loader Menu");
     
     	// Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
	if (GUI.Button (new Rect(20,40,150,20), "download images and texture")) {

		
	 	 string Url ="http://images.earthcam.com/ec_metros/ourcams/fridays.jpg";
		StartCoroutine(_LoadTexture(Url, gameObject));
	}
	
	
	}
	
	/*
	 public string url = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg";
     IEnumerator Start() {
        WWW www = new WWW(url);
        yield return www;
		transform.renderer.material.mainTexture = www.texture;
       // renderer.material.mainTexture = www.texture;
    }
	
	*/
	
    void Start()
    {
        
    }
    private IEnumerator _LoadTexture(string url, GameObject obj)
    {
        WWW rerquest = new WWW(url);
		
        yield return rerquest;
        transform.renderer.material.mainTexture = rerquest.texture;
     
    }
	
}

shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Unity3D4

Amazon

adsbygoogle

Recent Posts

Categories

Amazon