Author Topic: Adding an animated Sprite inside UIWidget?  (Read 3708 times)

johanesnw

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 22
    • View Profile
Adding an animated Sprite inside UIWidget?
« on: April 30, 2014, 10:57:42 AM »
for now let these pics speaks. It's com2us' new game Knights n Squires
Screenshot_2014-04-30-22-02-24.png
Screenshot_2014-04-30-22-02-04.png

I've tried to do this weeks ago but it I got no clue and moved on to another problem.
is NGUI capable to do this stuff? cos I really need this in my game.
could you put a Sprite inside UIWidget? actually not a sprite but a Prefab that contains many sprites.

thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Adding an animated Sprite inside UIWidget?
« Reply #1 on: April 30, 2014, 05:50:15 PM »
Your post is about animated sprites, and you say the pics will speak for themselves, then proceed to link two static non-animated images? :P

UISpriteAnimation is a very basic script that shows how to do animations by switching sprites. You can do what you want.

johanesnw

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: Adding an animated Sprite inside UIWidget?
« Reply #2 on: April 30, 2014, 11:00:36 PM »
aww I'm sorry. I was sleepy yesterday..
actually I wanna ask about how to put the object inside the UIwidget. and 2D objects are sprites.
and those objects are not part of UI. they're prefab that you also use in the game.

lets take another example here
dota2 ui
it has a "Card" UI containing heroes face in idle animation.
or this pic from google
it has the same hero object in game and inside the UI, but maybe that's not animated.

I've tried dragging the object inside uiwidget, and when I play its not the place I put inside scene editor.
because UI use UIRoot>Camera and objects use MainCamera to render.
then I try screenToWorldPoint and set to (0.5,0.5) point of screen to place in in the center.
but it's not working as I wanted.

so I can ask once again :p
is NGUI capable to do this stuff?

=====
another question:
- does uisprite only accept pic from created Atlas?
I have 40~ enemies here. and want to take the face sprite to HPbar UI.
is it possible to assign the sprite to uisprite without creating an atlas?
=====

thanks.
and sorry for the trouble  ;D

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Adding an animated Sprite inside UIWidget?
« Reply #3 on: May 02, 2014, 07:31:57 AM »
1. You need to set up a render texture, camera render into that render texture, and then display that texture using UITexture. It would be a Unity question. All NGUI would do is just draw the render texture using UITexture. The rest is all Unity.

2. Yes. UITexture.