playMaker

Author Topic: Set a NGUI Sprite from a texture loaded from the web  (Read 18391 times)

Tropical Cyborg

  • Playmaker Newbie
  • *
  • Posts: 23
  • Meet Tropical Cyborg
    • Tropical Cyborg
Set a NGUI Sprite from a texture loaded from the web
« on: July 28, 2013, 06:14:18 PM »
I am trying to load a user's avatar picture captured from the web and load it on a NGUI sprite using Playmaker. I am using a Get property action to save the picture. But when I try to load it on the NGUI sprite with a Set Property->UISprite->Texture  action it messes my texture Atlas completely. I believe the reason is that the avatar picture texture is not contained on the Atlas. Is there a workaround for this problem or an action with which I could include the avatar picture on the texture Atlas to use it?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set a NGUI Sprite from a texture loaded from the web
« Reply #1 on: July 29, 2013, 03:24:50 AM »
Hi,

 You need to use a special ngui sprite for this. it's in the ngui menu "Create texture", and the component is a UITexture. then it's not linked to any atlas, it justs shows the texture as is.

bye,

 Jean

Tropical Cyborg

  • Playmaker Newbie
  • *
  • Posts: 23
  • Meet Tropical Cyborg
    • Tropical Cyborg
Re: Set a NGUI Sprite from a texture loaded from the web
« Reply #2 on: July 29, 2013, 11:06:26 AM »
Thanks, Jean. I'll try it!

Tropical Cyborg

  • Playmaker Newbie
  • *
  • Posts: 23
  • Meet Tropical Cyborg
    • Tropical Cyborg
Re: Set a NGUI Sprite from a texture loaded from the web
« Reply #3 on: July 29, 2013, 09:55:20 PM »
I am able to get the texture from the web and save it as an Object variable -> UnityEngine -> Texture2D. I can't save it as a Texture variable, the GetProperty action I am using to talk to my script doesn't recognises the texture variable. But when I use a Set property to the NGUI texture, it doesn't recognises the Texture 2D object as a variable, it just recognises Texture variables. This way I cannot set the texture of the NGUI texture to the texture loaded from the web. Can anybody help me?
« Last Edit: July 29, 2013, 09:57:05 PM by Tropical Cyborg »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set a NGUI Sprite from a texture loaded from the web
« Reply #4 on: July 30, 2013, 06:03:08 AM »
Hi,

 Here's an example of a UITexture that I set its texture with a FsmTexture variable. Now if, your texture is empty when you get it from a url, it means the url is not a valid texture, that would be another problem.

Bye,

 Jean

Tropical Cyborg

  • Playmaker Newbie
  • *
  • Posts: 23
  • Meet Tropical Cyborg
    • Tropical Cyborg
Re: Set a NGUI Sprite from a texture loaded from the web
« Reply #5 on: July 30, 2013, 12:23:45 PM »
That's exactly what I was doing but for some reason it was not working. The problem was when I was trying to Get the texture from the web and save it as a FSM Texture. Actually I solved the issue with a workaround. I've loaded the texture from the web on a GUITexture Game object. Used the Get property action to save the texture from the GUItexture object on a FSMTexture variable. And only them I was able to load it on the NGUI texture. It worked but it would be nice if there was a more intuitive way of do it.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set a NGUI Sprite from a texture loaded from the web
« Reply #6 on: July 31, 2013, 02:47:24 AM »
Hi,

 that's very odd indeed... I am using www texture loading and it works fine. could you share ( pm me if it's private) the url to that image and I'll test.

bye,

 Jean

Tropical Cyborg

  • Playmaker Newbie
  • *
  • Posts: 23
  • Meet Tropical Cyborg
    • Tropical Cyborg
Re: Set a NGUI Sprite from a texture loaded from the web
« Reply #7 on: July 31, 2013, 03:37:58 PM »
Actually it is my avatar from Facebook. I am developing a Facebook App and I need to load the user's avatars on the game GUI. I'm don't think you would be able to load my avatar but you can try with your own.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set a NGUI Sprite from a texture loaded from the web
« Reply #8 on: July 31, 2013, 03:41:57 PM »
Hi,
 
I think you need to use Fb graph to access that kind of data, where did you get the url from?

bye,

 Jean

Tropical Cyborg

  • Playmaker Newbie
  • *
  • Posts: 23
  • Meet Tropical Cyborg
    • Tropical Cyborg
Re: Set a NGUI Sprite from a texture loaded from the web
« Reply #9 on: July 31, 2013, 03:47:29 PM »
I am using the Unity Facebook App package from the Asset Store.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set a NGUI Sprite from a texture loaded from the web
« Reply #10 on: August 05, 2013, 03:26:26 AM »
Hi,

 have you contacted the author to see about getting a texture from facebook api? he may very well have a solution and tips for this.

bye,

 Jean

Tropical Cyborg

  • Playmaker Newbie
  • *
  • Posts: 23
  • Meet Tropical Cyborg
    • Tropical Cyborg
Re: Set a NGUI Sprite from a texture loaded from the web
« Reply #11 on: August 05, 2013, 10:48:21 AM »
The package sends a URL for a WWWTexture with a GetUnity call. The script than saves the texture as a variable. It worked loading this variable on a GUITexture with this script but could not save this texture variable from the script with a Get Property Action.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set a NGUI Sprite from a texture loaded from the web
« Reply #12 on: August 06, 2013, 03:31:14 AM »
Hi,

If you have your texture in a FsmTexture, why are using "Get Property" action? to what component your "Get property" action is pointing?

bye,

 Jean

Tropical Cyborg

  • Playmaker Newbie
  • *
  • Posts: 23
  • Meet Tropical Cyborg
    • Tropical Cyborg
Re: Set a NGUI Sprite from a texture loaded from the web
« Reply #13 on: August 06, 2013, 09:27:06 AM »
To the script that loads the texture from the url sent from facebook.