Author Topic: Hit test on a UITextList Paragraph.  (Read 3085 times)

SGE

  • Guest
Hit test on a UITextList Paragraph.
« on: June 16, 2013, 10:28:53 PM »
Hi all,

First off much love to NGUI.
I'm developing a game that was planned only for Windows (C#) and thought I try Unity3D to leave the 'cross-platform' door open. Native Unity was a bad fit for what I am doing (all 2D) but NGUI was bang on the money.

In the game I'm going to be dynamically generating lots of text via code and Adding it to a UITextList control.
Some of the Paragraphs will be selectable options and I need to be able to Hit/Click/Tap Test them and work out which one the user chose.

I'm still getting used to how Unity hangs componentry together so if anyone has any pointers on how to identify a hit Paragraph they would be most greatfully received.

Many thanks & happy coding.

A.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Hit test on a UITextList Paragraph.
« Reply #1 on: June 18, 2013, 12:35:41 AM »
The text list script is an example script, so you should modify it to suit your needs. Basically when it creates individual line labels, simply add a collider to them (using NGUITools.AddCollider), and they will be clickable. If you need to have any kind of data associated with the lines (such as name of the player that said something), I advise creating a script that you can attach to these labels as well. This same script that will respond to your OnClick event can hold any additional data you need.

SGE

  • Guest
Re: Hit test on a UITextList Paragraph.
« Reply #2 on: June 18, 2013, 09:46:09 PM »
Sweet  :D

I think I was slowly working my way to a similar approach.
Cheers and thanks again for creating a great product.

I hope my license fee goes towards some beers or something equally relaxing.  8)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Hit test on a UITextList Paragraph.
« Reply #3 on: June 19, 2013, 12:21:32 AM »
I don't drink, but I do eat cookies. Lots of them. So... close? :P