Author Topic: Dynamic data loading.  (Read 8963 times)

skyRider

  • Guest
Dynamic data loading.
« on: July 12, 2012, 02:55:51 AM »
Hi Aren i have few questions , i am just transferring my game from IOS to unity and i chose NGUI to work. I have following questions:

  1) i have to setUp animation on sprites that it become moving and walking.. but i dont have sprite sheets i have a server and it returns me separate  frames. how to make them as a animation which scripts are best to do  that.
  2) i have to implement store and in store all data is coming through server side at runtime how i populate cells with different images that are coming from server.
  3) does sprite takes touch? if not is it doable by some modification?
 
Thanks for now these are the questions. Probably i will need more help in future also

joreldraw

  • Guest
Re: Dynamic data loading.
« Reply #1 on: July 12, 2012, 03:49:15 AM »
1 & 2 : http://docs.unity3d.com/Documentation/ScriptReference/WWW.html

3: You can make your sprite touchable. Need a Collider & Button Script for the action. More easy if directly make a Button Widget, this add a sprite "Background" & UILabel "Label". Select the sprite you like in background and remove the label if not needed.

skyRider

  • Guest
Re: Dynamic data loading.
« Reply #2 on: July 12, 2012, 04:06:33 AM »
Yes i know SPRITE WITH BUTTON property. but in my case my sprite is on random movement and when i tap to it it increases it speeds of movement for a while and there are too many sprites on the screen. and they are coming dynamically for server. and their sized scaling with passage of time. Thats my issue

joreldraw

  • Guest
Re: Dynamic data loading.
« Reply #3 on: July 12, 2012, 04:27:19 AM »
Add the collider & the script to the sprite.

Scale the transform.localscale not the sprite to scale the collider too and all go in same group without problem.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamic data loading.
« Reply #4 on: July 12, 2012, 04:47:10 AM »
For #1, if you are not using an atlas then you will want to use a UITexture to display your sprites.

skyRider

  • Guest
Re: Dynamic data loading.
« Reply #5 on: July 12, 2012, 05:34:32 AM »
@joreldraw
Thanks for telling about downloading on runtime. But this is that every time data is downloaded from server , i want once it downloaded it stores to my local Device storage and i retrive from there next time.

Let me try for collider and localscale property


skyRider

  • Guest
Re: Dynamic data loading.
« Reply #6 on: July 12, 2012, 05:35:35 AM »
@aren
Yes i will Use UITexture. Is there any script in NGUI that i apply Frame changing animation to Textures.

joreldraw

  • Guest
Re: Dynamic data loading.
« Reply #7 on: July 12, 2012, 05:43:11 AM »
What you are asking is loading in runtime, same for web & for localdrive.

You can make a first download of all resources from server if animation is not update all time and later load from downloaded folder.

  1. string imagePath = "file://C:/BLA_BLA/Image_Series/" + imageName + ".png";
  2. WWW www = new WWW(imagePath);
  3. loadImageUrl(www);
  4.  


skyRider

  • Guest
Re: Dynamic data loading.
« Reply #8 on: July 12, 2012, 05:49:45 AM »
Cool..

So first downloaded from server at runtime and then it going to save on path in device. and then retrieve from that path next time. Thats what exactly i want Thankyou:)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamic data loading.
« Reply #9 on: July 12, 2012, 08:39:30 AM »
@aren
Yes i will Use UITexture. Is there any script in NGUI that i apply Frame changing animation to Textures.
Not to textures, no.

skyRider

  • Guest
Re: Dynamic data loading.
« Reply #10 on: July 13, 2012, 12:38:37 AM »
So how to achieve that functionality.

joreldraw

  • Guest
Re: Dynamic data loading.
« Reply #11 on: July 13, 2012, 02:49:24 AM »
You can't make your server send you a Sprite animation?

If not you go to overload your system with a lot of extra operations.

You can make a Texture List loading all frames. Nice if you have a sequency how "MyAnimation01.png" "..02.png" "...03.png"

With the list maked need to do a code to increment the texture name frame per frame how you like.




ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamic data loading.
« Reply #12 on: July 13, 2012, 08:42:55 AM »
So how to achieve that functionality.
I suggest looking into how UISpriteAnimation works, it's a pretty short script. You can write a version that works with a UITexture easily enough -- instead of swapping sprites you will need to swap the material's texture.

skyRider

  • Guest
Re: Dynamic data loading.
« Reply #13 on: July 16, 2012, 01:36:11 AM »
@joralDraw
Thats our badluck that we cant change server , because we are converting game from IOS to unity using NGUI. Thats why server has been made previously. So it cannot be change as other versions are running on same server i.e. IOS , Android.

I know i have do lot of operation that is why i am discussing here to find some optimise and best solution.


@ Aren
Ahan let me give a look to UISpriteAnimation Thankyou

skyRider

  • Guest
Re: Dynamic data loading.
« Reply #14 on: July 16, 2012, 04:53:43 AM »
After animation i want to move my Sprite to Random postions with in the screen is there any movement script like ITWEEN in NGUI that provide a smooth and crispy random movement with in given boundry