123456789101112131415161718192021222324252627282930313233343536373839 |
- using System;
- using System.Collections;
- using UnityEngine;
- [RequireComponent(typeof(UITexture))]
- public class DownloadTexture : MonoBehaviour
- {
- private IEnumerator Start()
- {
- WWW www = new WWW(this.url);
- yield return www;
- this.mTex = www.texture;
- if (this.mTex != null)
- {
- UITexture component = base.GetComponent<UITexture>();
- component.mainTexture = this.mTex;
- if (this.pixelPerfect)
- {
- component.MakePixelPerfect();
- }
- }
- www.Dispose();
- yield break;
- }
- private void OnDestroy()
- {
- if (this.mTex != null)
- {
- UnityEngine.Object.Destroy(this.mTex);
- }
- }
- public string url = "http://www.yourwebsite.com/logo.png";
- public bool pixelPerfect = true;
- private Texture2D mTex;
- }
|