Author Topic: How to make speech bubble with NGUI: HUD text ?  (Read 11117 times)

sahyun1

  • Guest
How to make speech bubble with NGUI: HUD text ?
« on: December 05, 2013, 05:36:14 AM »
Hi guys
I'm making 2D game with new Unity 4.3
I've bought NGUI:HUD text and it works great I really like it. But I would like a some sort of box around HUD text, something like a speech bubble.
How can I achieve this?

My initial thought is to use srpite renderer on the gameObject above the player's head and display the text but this would be very difficult to set the size of bubble as it would be a static

I'm sure there's some more elegant way, any thoughts will be helpful!

thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to make speech bubble with NGUI: HUD text ?
« Reply #1 on: December 05, 2013, 03:54:48 PM »
That's a good idea actually. I'll see about making an example of that after this weekend's release of NGUI 3.0.7.

sahyun1

  • Guest
Re: How to make speech bubble with NGUI: HUD text ?
« Reply #2 on: December 05, 2013, 08:58:05 PM »
Thank you, that would be great!
Hope to see your example soon  :)

triawyn

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: How to make speech bubble with NGUI: HUD text ?
« Reply #3 on: December 10, 2013, 11:32:44 AM »
i actually made this awhile back before i upgraded to 3.07 but now the localscale variable doesnt work so i am having to rewrite the parts that scale the bubble to the text width per line.  once i finish i can post it.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to make speech bubble with NGUI: HUD text ?
« Reply #4 on: December 10, 2013, 11:36:18 PM »
No need to write code. Set the anchor on your sliced sprite to be the label, and give it some padding. It will scale automatically to envelop the content.

sahyun1

  • Guest
Re: How to make speech bubble with NGUI: HUD text ?
« Reply #5 on: December 12, 2013, 06:26:37 AM »
Thank you for help guys, but I'm completely new to Unity, would you be able to elaborate little bit more??

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to make speech bubble with NGUI: HUD text ?
« Reply #6 on: December 12, 2013, 06:37:46 AM »
I can't elaborate it further than that, unfortunately. All I can suggest is watch the tutorial videos that come with NGUI:

http://www.tasharen.com/forum/index.php?topic=6754.0

This one explains the layout system and how to use it: http://www.youtube.com/watch?v=P8JTTE0JBXQ

The latest HUDText does exactly this for the description label anchored to the bottom. Try it -- open one of the examples and change the text on the bottom. The background will resize to match.

sahyun1

  • Guest
Re: How to make speech bubble with NGUI: HUD text ?
« Reply #7 on: December 18, 2013, 07:33:54 AM »
Hi there

I just updated NGUI HUD text, as stated in readme 1.9, I delete the example folder and script folder, and use hudtext_ngui270.unitypackage.

Now, I have readme 1.6, is this correct? is my NGUI HUD text asset properly updated?

sahyun1

  • Guest
Re: How to make speech bubble with NGUI: HUD text ?
« Reply #8 on: December 18, 2013, 07:35:54 AM »
I'm asking this because even I change the text on bottom, the surrounding box does not shrink

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to make speech bubble with NGUI: HUD text ?
« Reply #9 on: December 18, 2013, 01:03:14 PM »
hudtext_ngui270.unitypackage is the old version of HUDText for those who are not using NGUI 3.

Why are you importing it? Don't do it. When you import HUDText you already have the latest version. Don't import the outdated package.

sahyun1

  • Guest
Re: How to make speech bubble with NGUI: HUD text ?
« Reply #10 on: December 18, 2013, 05:57:28 PM »
Hi

That's because I only purchased NGUI HUD text, not the whole package, so using distributed one, version 2.7.
It says use hudtext_ngui270.unitypackage if I have NGUI 2.7 or earlier

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to make speech bubble with NGUI: HUD text ?
« Reply #11 on: December 18, 2013, 06:02:59 PM »
Ok, well you haven't mentioned that before. My advice was for the latest version of NGUI. 2.7.0 isn't supported anymore, which is why it's unofficially free. Without NGUI 3, you can achieve the same effect by making the background a child of your label, then putting UIStretch on it and targeting the label as the container so that it stretches the background to envelop it.

But as I said... 2.7.0 is not supported anymore.