LoadImageIntoTexture() private method

private LoadImageIntoTexture ( Texture2D tex ) : void
tex Texture2D
return void
コード例 #1
0
ファイル: TermWindow.cs プロジェクト: raad287/KOS
        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;
        }
コード例 #2
0
ファイル: LoadSlides.cs プロジェクト: typhomnt/VR_Meetig_Room
 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;
 }
コード例 #3
0
        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;
        }
コード例 #4
0
    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");
        }
    }
コード例 #5
0
 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);
 }
コード例 #6
0
ファイル: TextureIo.cs プロジェクト: ttat/puzzlewarrior
        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;
        }
コード例 #7
0
    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");
    }
コード例 #8
0
ファイル: loadPic.cs プロジェクト: Sam-Edge/Goose-Island-App
    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);

        }
    }
コード例 #9
0
    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();
    }
コード例 #10
0
 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]);
 }
コード例 #11
0
 static public int LoadImageIntoTexture(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.WWW       self = (UnityEngine.WWW)checkSelf(l);
         UnityEngine.Texture2D a1;
         checkType(l, 2, out a1);
         self.LoadImageIntoTexture(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
コード例 #12
0
ファイル: MapS.cs プロジェクト: ropnom/UnityServerSocket
	// 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;
	}
コード例 #13
0
ファイル: KOSTextEditPopup.cs プロジェクト: KSP-KOS/KOS
 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);
 }
コード例 #14
0
    IEnumerator HttpLoadTexture(string url, Texture2D inTex, Action onComplete)
    {
        WWW www = new WWW(url);
        yield return www;

        www.LoadImageIntoTexture(inTex);

        onComplete();
    }
コード例 #15
0
	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);
	}
コード例 #16
0
    // ------------------------------------------------------------------
    // 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 );
    }
コード例 #17
0
ファイル: Lobby.cs プロジェクト: ronforbes/BlockParty1
 IEnumerator GetProfilePicture(string facebookId)
 {
     WWW www = new WWW("https" + "://graph.facebook.com/" + facebookId + "/picture");
     Debug.Log("Loading profile picture");
     yield return www;
     Texture2D pictureTexture = new Texture2D(128, 128, TextureFormat.DXT1, false);
     PersonalPicture.texture = pictureTexture;
     www.LoadImageIntoTexture(pictureTexture);
     Debug.Log("Loaded profile picture");
 }
コード例 #18
0
ファイル: LeaderBoardScript.cs プロジェクト: Kunjky/Mr.Bigger
	public IEnumerator getFBPicture(GameObject g, string facebookId) {
		var www = new WWW("http://graph.facebook.com/" + facebookId + "/picture?type=square");
		
		yield return www;
		
		Texture2D tempPic = new Texture2D(25, 25);

		www.LoadImageIntoTexture(tempPic);
		g.transform.FindChild("avatar").GetComponent<RawImage>().texture = tempPic;
	}
コード例 #19
0
	public IEnumerator getPic()
	{
		var www = new WWW ("http://graph.facebook.com/" + FB.UserId + "/picture?type=square");
		yield return www;
		
		pictex = new Texture2D (25, 25);
		www.LoadImageIntoTexture (pictex);
		
		showPic = true;
	}
コード例 #20
0
    // Gets our facebook profile picture
    public IEnumerator GetFBPicture()
    {
        var www = new WWW("http://graph.facebook.com/" + facebookID + "/picture?type=square");

        yield return www;

        Texture2D tempPic = new Texture2D(50,50);

        www.LoadImageIntoTexture(tempPic);
        profilePic.mainTexture = tempPic;
    }
コード例 #21
0
        internal override void StartEvent()
        {
            started = true;
            string url = "file://" + Application.dataPath + "/Mods/Resources/EventMod/Images/ThisIsTruuump.jpg";
            Debug.Log(url);
            WWW www = new WWW(url);

            trump = new Texture2D(1,1);
            www.LoadImageIntoTexture(trump);
            textureLoaded = true;
        }
コード例 #22
0
 IEnumerator WaitAndLoadImage(WWW www)
 {
     yield return www;
     // assign the downloaded image to the main texture of the object
     //		Debug.LogError (">>>> www.texture size " + www.texture.width + " " + www.texture + " url " + url);
     www.LoadImageIntoTexture(GetComponent<Renderer>().material.mainTexture as Texture2D);
     Texture2D t = GetComponent<Renderer> ().material.mainTexture as Texture2D;
     Sprite sprite = Sprite.Create (t, new Rect (0, 0, t.width, t.height), new Vector2 (0.5f, 0.5f));
     SpriteRenderer render = GetComponent<SpriteRenderer> ();
     render.sprite = sprite;
 }
コード例 #23
0
    IEnumerator GetWWW(int st)
    {
        www = new WWW(urls[st]);
        int frames = 0;
        while (www != null && !www.isDone)
        {
            m_info = "Loading... " + frames;
            frames++;
            yield return new WaitForEndOfFrame();
        }

        if (!string.IsNullOrEmpty(www.error))
        {
            m_info = "Error: " + www.error;
        }
        else
        {
            m_info = "Done!";
            switch (st)
            {
                case 0:
                    {
                        m_info += " Press Mouse Button 2 to load texture";
                        tex = null;
                        if (www.audioClip != null)
                        {
                            _audio = www.GetAudioClip(false, false, AudioType.WAV);
                            if (_audio == null)
                                yield return new WaitForEndOfFrame();
                            else
                                gameObject.GetComponent<AudioSource>().clip = _audio;
                        }
                        break;
                    }
                case 1:
                    {
                        m_info += " Press Mouse Button 2 to load texture (non readable) and load into texture";
                        _audio = null;
                        gameObject.GetComponent<AudioSource>().clip = null;
                        if (www.texture != null)
                            tex = www.texture;
                    }
                    break;
                case 2:
                    {
                        m_info += " Press Mouse Button 2 to load sound";
                        if (www.textureNonReadable != null)
                            www.LoadImageIntoTexture(tex);

                    }
                    break;
            }
        }
    }
コード例 #24
0
 public static IEnumerator LoadImage(this Texture2D texture2D, string url, Vector2 size, TextureFormat format = TextureFormat.RGB24, bool mipmap = false)
 {
     Texture2D tex = new Texture2D((int)size.x, (int)size.y, format, mipmap);
     WWW www = new WWW(url);
     yield return www;
     if (string.IsNullOrEmpty(www.error))
     {
         www.LoadImageIntoTexture(tex);
         texture2D = tex;
     }
 }
コード例 #25
0
	public IEnumerator getFBPicture()
	{
		var www = new WWW("http://graph.facebook.com/" + facebookId + "/picture?type=square");

		// wait until the download is done
		yield return www;

		// assign the downloaded image to the main texture of the object
		www.LoadImageIntoTexture(fbPic);
	//	profilePicture.mainTexture = fbPic;
	}
コード例 #26
0
ファイル: MapFriend.cs プロジェクト: SonGit/NailGame
	IEnumerator UserImage(string url, MeshRenderer image)
	{

		WWW www = new WWW(url); 
		Texture2D textFb2 = new Texture2D(128, 128, TextureFormat.DXT1, false); //TextureFormat must be DXT5
		yield return www;
		www.LoadImageIntoTexture(textFb2);
		image.material.mainTexture = textFb2;
		image.material.shader = Shader.Find ("Sprites/Default");
		image.material.color = Color.white;
	}
コード例 #27
0
    private IEnumerator LoadTexture(WWW www, Action<Texture2D> callback)
    {
        yield return www;

        if (string.IsNullOrEmpty(www.error)) {
            Texture2D tex = new Texture2D(4, 4, TextureFormat.RGB24, false);
            www.LoadImageIntoTexture(tex);
            callback(tex);
        } else {
            callback(null);
        }
    }
コード例 #28
0
ファイル: GUITest.cs プロジェクト: lnanek/FLIRHack
    IEnumerator load_image()
    {
        Debug.Log("load_image");

        // get every file in chosen directory with the extension .jpg

        string pathForThermalImages = Application.dataPath + "/../..";
        if (Application.platform == RuntimePlatform.Android) {
            pathForThermalImages = "/sdcard/Pictures/";
        }

        string[] filePaths = Directory.GetFiles(pathForThermalImages, "FLIROne-*.jpg");
        if (filePaths.Length == 0) {
            Debug.Log("no FLIR files found");
            isLoading = false;
            yield return null;
        }

        // Read the newest file
        Array.Sort(filePaths);
        Array.Reverse(filePaths);
        string newestFilePath = filePaths[0];

        // Delete older files
        if (filePaths.Length > 1) {
            for(int i = 1; i < filePaths.Length; i++) {
                File.Delete(filePaths[i]);
            }
        }

        // If we already loaded the image, ignore it
        if ( null != lastLoadedFilePath ) {
            if ( 0 == String.Compare(lastLoadedFilePath, newestFilePath) ) {
                Debug.Log("newest file is same as last loaded, stopping");
                isLoading = false;
                yield return null;
            }
        }

        // "download" the first file from disk
        WWW www = new WWW("file://" + newestFilePath);

        // Wait unill its loaded
        yield return www;

        // put the downloaded image file into the Texture2D
        www.LoadImageIntoTexture(loadingTexture);

        lastLoadedFilePath = newestFilePath;

        isLoading = false;
        isFirstLoaded = true;
    }
コード例 #29
0
ファイル: Rendering.cs プロジェクト: SCI-parina/blockofwars
    // Use this for initialization
    IEnumerator Start()
    {
        var url = "http://doge.naurunappula.com/screen/0d/2e/0d2ed4f4e7d37d9d/0/1299237.png";
        gameObject.GetComponent<Renderer>().material.SetTexture("_MainTex", texture);
        while (true)
        {
            var www = new WWW(url);
            yield return www;
            www.LoadImageIntoTexture(gameObject.GetComponent<Renderer>().material.mainTexture as Texture2D);

        }
    }
コード例 #30
0
ファイル: ImageFeed.cs プロジェクト: guanwenhu/imola-unity
 IEnumerator LoadImage(string imagePath)
 {
     Debug.Log("Image path is " + imagePath + ";full path is " + "file://" + System.IO.Path.GetFullPath(imagePath).Replace('\\','/'));
     WWW req = new WWW("file://" + System.IO.Path.GetFullPath(imagePath).Replace('\\','/'));
     yield return req;
     //transform.Find("Image").localScale = new Vector3((float)req.texture.width / (float)req.texture.height, 1.0f, 1.0f);
     //transform.Find("Image").renderer.material.mainTexture = req.texture;
     Texture2D image = new Texture2D(64, 64);
     req.LoadImageIntoTexture(image);
     Debug.Log("loaded one image");
     images.Add(image);
 }
コード例 #31
0
 static public int LoadImageIntoTexture(IntPtr l)
 {
     try {
         UnityEngine.WWW       self = (UnityEngine.WWW)checkSelf(l);
         UnityEngine.Texture2D a1;
         checkType(l, 2, out a1);
         self.LoadImageIntoTexture(a1);
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #32
0
 public static IEnumerator LoadTexture2D(this Texture2D te, string url, Vector2 size, TextureFormat format = TextureFormat.RGB24, bool mipmap = false)
 {
     Texture2D tex = new Texture2D((int)size.x, (int)size.y, format, mipmap);
     //tex.name = "Demo";
     WWW www = new WWW("file:///" + url);
     yield return www;
     Debug.Log(url);
     if (string.IsNullOrEmpty(www.error))
     {
         www.LoadImageIntoTexture(tex);
         te = tex;
     }
 }
コード例 #33
0
 static int QPYX_LoadImageIntoTexture_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 2);
         UnityEngine.WWW       QPYX_obj_YXQP  = (UnityEngine.WWW)ToLua.CheckObject <UnityEngine.WWW>(L_YXQP, 1);
         UnityEngine.Texture2D QPYX_arg0_YXQP = (UnityEngine.Texture2D)ToLua.CheckObject(L_YXQP, 2, typeof(UnityEngine.Texture2D));
         QPYX_obj_YXQP.LoadImageIntoTexture(QPYX_arg0_YXQP);
         return(0);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
コード例 #34
0
 static int LoadImageIntoTexture(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.WWW       obj  = (UnityEngine.WWW)ToLua.CheckObject(L, 1, typeof(UnityEngine.WWW));
         UnityEngine.Texture2D arg0 = (UnityEngine.Texture2D)ToLua.CheckUnityObject(L, 2, typeof(UnityEngine.Texture2D));
         obj.LoadImageIntoTexture(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #35
0
    static int LoadImageIntoTexture(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("UnityEngine.WWW.LoadImageIntoTexture");
#endif
        try
        {
            ToLua.CheckArgsCount(L, 2);
            UnityEngine.WWW       obj  = (UnityEngine.WWW)ToLua.CheckObject <UnityEngine.WWW>(L, 1);
            UnityEngine.Texture2D arg0 = (UnityEngine.Texture2D)ToLua.CheckObject(L, 2, typeof(UnityEngine.Texture2D));
            obj.LoadImageIntoTexture(arg0);
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #36
0
        static int _m_LoadImageIntoTexture(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1);


            try {
                {
                    UnityEngine.Texture2D tex = (UnityEngine.Texture2D)translator.GetObject(L, 2, typeof(UnityEngine.Texture2D));

                    __cl_gen_to_be_invoked.LoadImageIntoTexture(tex);



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
        // core of the previous function
        // IObserver is a callback publisher
        // Note: IObserver's basic scheme is "OnNext* (OnError | Oncompleted)?"
        static IEnumerator GetWWWTextureCore(string url, IObserver <Texture2D> observer, IProgress <float> reportProgress, CancellationToken cancellationToken)
        {
            var request = new UnityEngine.WWW(url);

            while (!request.isDone && !cancellationToken.IsCancellationRequested)
            {
                if (reportProgress != null)
                {
                    reportProgress.Report(request.progress);
                }
                yield return(null);
            }

            if (cancellationToken.IsCancellationRequested)
            {
                yield break;
            }

            if (request.error != null)
            {
                observer.OnError(new Exception(request.error));
            }
            else
            {
                if (reportProgress != null)
                {
                    reportProgress.Report(request.progress);
                }
                Texture2D tex = new Texture2D(request.texture.width, request.texture.height, TextureFormat.RGBA32, false);
                request.LoadImageIntoTexture(tex);
                observer.OnNext(tex);
                observer.OnCompleted(); // IObserver needs OnCompleted after OnNext!

                // clean the request object
                request.Dispose();
                request = null;
                tex     = null;
            }
        }
コード例 #38
0
        protected override IEnumerator SendRequest()
        {
            Texture2D tex;

            tex = new Texture2D(_width, _height, _format, false);
            using (UnityEngine.WWW www = new UnityEngine.WWW(Uri))
            {
                yield return(www);

                try
                {
                    www.LoadImageIntoTexture(tex);
                    ResponseTexture responseTexture = new ResponseTexture();
                    responseTexture.Texture = tex;
                    ((IRequest)this).OnResponseDone(responseTexture);
                }
                catch (Exception e)
                {
                    ((IRequest)this).OnResponseError("Texture can not be loaded! " + e.Message);
                }
            }
        }