本文整理汇总了C#中UnityEngine.WWW.LoadImageIntoTexture方法的典型用法代码示例。如果您正苦于以下问题:C# WWW.LoadImageIntoTexture方法的具体用法?C# WWW.LoadImageIntoTexture怎么用?C# WWW.LoadImageIntoTexture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.WWW
的用法示例。
在下文中一共展示了WWW.LoadImageIntoTexture方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetProfilePic
IEnumerator GetProfilePic()
{
// one way to get the current user's profile picture into Unity
if (FB.IsLoggedIn) {
Debug.Log("retrieveing profile pic");
//string url = "https" + "://graph.facebook.com/" + FB.UserId + "/picture?type=large";
//url += "&access_token=" + FB.AccessToken;
//string url = "https://graph.facebook.com/545657492/picture?type=" +
// "large&access_token=CAAF8ZCA9fvhwBAK0eJ6kiUA1WWNWfWiSEI7q3rs1Soj6MMkbXZCm37MFyTT2OBCRzU2ZAiKK8m8YL6ZAIVmgoWUy1VZAV8231eODMV0ivvOjj9ZAhb5gGJ41UligKauZCNAnvRStuiYUeVXK36xOUBZBnwMuQSAHa3xJkZBof5kOa4e6j3V61EkLnZBIHepuYnfgEZD";
var dict = Json.Deserialize(jsonResult) as Dictionary<string,object>;
Dictionary<string,object> dataDict = dict["data"] as Dictionary<string,object>;
WWW www = new WWW((string) dataDict["url"]);
//Texture2D picTexture = new Texture2D(width, height, TextureFormat.DXT1, false);
yield return www;
www.LoadImageIntoTexture(lastResponseTexture);
//WWW www = new WWW (url);
//yield return www;
Debug.Log ("..success" + lastResponseTexture.width + " " + lastResponseTexture.height);
//lastResponseTexture = www.texture;
}
else
{
Debug.Log("SCAM");
}
}
示例2: PicGet
private IEnumerator PicGet()
{
WWW www = new WWW (GM.GetComponent<TwitterAuth> ().imageUrls[0]);
yield return www;
www.LoadImageIntoTexture (GetComponent<Renderer>().material.mainTexture as Texture2D);
GM.GetComponent<TwitterAuth> ().imageUrls.RemoveAt (0);
}
示例3: ReadTextureFromFile
public static Texture2D ReadTextureFromFile(string filepath, int width, int height)
{
Texture2D texture = new Texture2D(width, height);
try
{
if (File.Exists(filepath))
{
using (BinaryReader reader = new BinaryReader(File.OpenRead(filepath)))
{
long length = reader.BaseStream.Length;
byte[] textureData = reader.ReadBytes((int)length);
WWW www = new WWW("file://" + filepath);
www.LoadImageIntoTexture(texture);
texture.LoadImage(textureData);
reader.Close();
}
}
}
catch (Exception ex)
{
Debug.LogError("Loading texture failed: " + ex.Message);
}
return texture;
}
示例4: LoadImages
private IEnumerator LoadImages()
{
//load all images in default folder as textures and apply dynamically to plane game objects.
_textList = new Texture2D[_files.Length];
Debug.Log (_textList.Length);
int dummy = 0;
foreach(string tstring in _files) {
string pathTemp = pathPrefix + tstring;
WWW www = new WWW(pathTemp);
yield return www;
Texture2D texTmp = new Texture2D(1024, 1024, TextureFormat.ARGB32, false);
www.LoadImageIntoTexture(texTmp);
_textList[dummy] = texTmp;
Debug.Log (texTmp);
_images[dummy].renderer.material.mainTexture = _textList[dummy];
if(dummy%2 == 0){
_images[dummy].transform.Rotate(180, -180, 180);
}
dummy++;
}
Debug.Log ("textures used");
}
示例5: DownloadThumbs
public IEnumerator DownloadThumbs(string url, int idx)
{
WWW www = new WWW(url);
yield return www;
thumbs[idx] = new Texture2D(100, 100);
www.LoadImageIntoTexture(thumbs[idx]);
}
示例6: LoadImage
IEnumerator LoadImage(WWW www)
{
yield return www;
Texture2D tempTex= new Texture2D(0, 0);
www.LoadImageIntoTexture(tempTex);
www.Dispose ();
int width = tempTex.width;
int height = tempTex.height;
float targetWidth = 0;
float targetHeight = 0;
if(width > height){
float ratio = 200f / width;
targetWidth = width * ratio;
targetHeight = height * ratio;
} else{
float ratio = 200f / height;
targetWidth = width * ratio;
targetHeight = height * ratio;
}
Debug.Log("width : "+targetWidth+", height : "+targetHeight);
tempTex = UtilMgr.ScaleTexture (tempTex, (int)targetWidth, (int)targetHeight);
byte[] bytes = tempTex.EncodeToPNG();
mTempFile = UtilMgr.GetDateTimeNow("yyyyMMddHHmmss.png");
mTempFile = Application.temporaryCachePath + "/" + mTempFile;
try{
System.IO.File.WriteAllBytes(mTempFile, bytes);
} catch{
mTempFile = "";
}
UploadFile();
}
示例7: UpdateCam
IEnumerator UpdateCam()
{
while (true)
{
string url = url1;
if(count == 2)
{url = url2;}
else if(count == 3)
{url = url3;}
else if(count == 4)
{url = url4;}
else if(count == 5)
{url = url5;}
else if(count == 6)
{url = url6;}
else if(count == 7)
{url = url7;}
else if(count == 8)
{url = url8;}
else if(count == 9)
{url = url9;}
else if(count == 10)
{url = url10;}
else{ Debug.Log("Error, cant get count"); }
WWW www = new WWW(url);
yield return www;
www.LoadImageIntoTexture((Texture2D)GetComponent<Renderer>().material.mainTexture);
}
}
示例8: LoadExternalCoroutine
private void LoadExternalCoroutine(string name, UIImage image)
{
string url = "file://" + GameManager.Instance.mainGame.ExternalResourcePath + "/" + name + ".jpg";
Debug.Log(name);
WWW www = new WWW(url);
if (string.IsNullOrEmpty(www.error))
{
www.LoadImageIntoTexture(loaderTexture);
Sprite sprite = Sprite.Create(loaderTexture,
new Rect(0, 0, loaderTexture.width, loaderTexture.height),
// new Rect(0, 0, www.texture.width, www.texture.height), //->this eat up memory!!
new Vector2(0.5f, 0.5f), 100.0f);
Sprite[] sprites = new Sprite[1];
sprites[0] = sprite;
image.SetSprites(sprites);
image.Sprite = 0;
DestroyImmediate(www.texture);
}
else
{
Debug.LogWarning(www.error);
image.SetSprites(UIManager.LoadSprite(name));
image.Sprite = 0;
}
www.Dispose();
www = null;
}
示例9: LoadTexture
public void LoadTexture(String relativePath, ref Texture2D targetTexture)
{
var imageLoader = new WWW("file://" + root + relativePath);
imageLoader.LoadImageIntoTexture(targetTexture);
if (imageLoader.isDone && imageLoader.size == 0) allTexturesFound = false;
}
示例10: updateTexture
private void updateTexture()
{
currentTexture = Mathf.Clamp(currentTexture, 0, textures.Length - 1);
var www = new WWW("file:///" + textures[currentTexture]);
www.LoadImageIntoTexture(texture);
player.GetComponent<Renderer>().material.mainTexture = texture;
}
示例11: Start
// Use this for initialization
IEnumerator Start () {
zoom14 = new Texture2D(1, 1, TextureFormat.ARGB32, true);
zoom15 = new Texture2D(1, 1, TextureFormat.ARGB32, true);
zoom16 = new Texture2D(1, 1, TextureFormat.ARGB32, true);
zoom17 = new Texture2D(1, 1, TextureFormat.ARGB32, true);
zoom18 = new Texture2D(1, 1, TextureFormat.ARGB32, true);
double lon = float.Parse(PositionUtilities.centerMapLon);
double lat = float.Parse(PositionUtilities.centerMapLat);
Point p = PositionUtilities.WorldToTilePosZoom(lon, lat, 14);
int x = Mathf.FloorToInt((float)p.X);
int y = Mathf.FloorToInt((float)p.Y);
x= x+ X;
y= y+ Y;
WWW www = new WWW("http://a.tile.openstreetmap.org/14/"+ x + "/ " + y + ".png");
yield return www;
www.LoadImageIntoTexture(zoom14);
p = PositionUtilities.WorldToTilePosZoom(lon, lat, 15);
x = Mathf.FloorToInt((float)p.X);
y = Mathf.FloorToInt((float)p.Y);
x= x+ X;
y= y+ Y;
www = new WWW("http://a.tile.openstreetmap.org/15/"+ x + "/ " + y + ".png");
yield return www;
www.LoadImageIntoTexture(zoom15);
p = PositionUtilities.WorldToTilePosZoom(lon, lat, 16);
x = Mathf.FloorToInt((float)p.X);
y = Mathf.FloorToInt((float)p.Y);
x= x+ X;
y= y+ Y;
www = new WWW("http://a.tile.openstreetmap.org/16/"+ x + "/ " + y + ".png");
yield return www;
www.LoadImageIntoTexture(zoom16);
p = PositionUtilities.WorldToTilePosZoom(lon, lat, 17);
x = Mathf.FloorToInt((float)p.X);
y = Mathf.FloorToInt((float)p.Y);
x= x+ X;
y= y+ Y;
www = new WWW("http://a.tile.openstreetmap.org/17/"+ x + "/ " + y + ".png");
yield return www;
www.LoadImageIntoTexture(zoom17);
p = PositionUtilities.WorldToTilePosZoom(lon, lat, 18);
x = Mathf.FloorToInt((float)p.X);
y = Mathf.FloorToInt((float)p.Y);
x= x+ X;
y= y+ Y;
www = new WWW("http://a.tile.openstreetmap.org/18/"+ x + "/ " + y + ".png");
yield return www;
www.LoadImageIntoTexture(zoom18);
//gameObject.GetComponent<Renderer>().material.mainTexture = zoom14;
zoom=0;
}
示例12: Awake
public void Awake()
{
var gObj = new GameObject("texteditConfirm", typeof(DelegateDialog));
DontDestroyOnLoad(gObj);
dialog = (DelegateDialog)gObj.GetComponent(typeof(DelegateDialog));
var urlGetter = new WWW(string.Format("file://{0}GameData/kOS/GFX/resize-button.png", KSPUtil.ApplicationRootPath.Replace("\\", "/")));
urlGetter.LoadImageIntoTexture(resizeImage);
}
示例13: HttpLoadTexture
IEnumerator HttpLoadTexture(string url, Texture2D inTex, Action onComplete)
{
WWW www = new WWW(url);
yield return www;
www.LoadImageIntoTexture(inTex);
onComplete();
}
示例14: LoadImage
public IEnumerator LoadImage(string fName) {
WWW www = new WWW ("file://" + Application.dataPath + "/" + fName);
yield return www;
myTex = new Texture2D (QrCodeWrapper.QR_DIMENSION, QrCodeWrapper.QR_DIMENSION);
myTex.name = fName;
www.LoadImageIntoTexture (myTex);
}
示例15: Init_CO
// ------------------------------------------------------------------
// Desc:
// ------------------------------------------------------------------
IEnumerator Init_CO( string _url, string _name, int _score )
{
WWW www = new WWW(_url);
yield return www;
Texture2D textureIcon = new Texture2D(80,80);
www.LoadImageIntoTexture(textureIcon);
Init( textureIcon, _name, _score );
}