Author Topic: How to use UIWidget.HitCheck delegate in my program.  (Read 2714 times)

pawankumar113

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 11
    • View Profile
How to use UIWidget.HitCheck delegate in my program.
« on: November 12, 2014, 04:48:01 AM »
How I can use UIWidget.HitCheck to detect a particular Sprite or GameObject hit or not when i touches on Screen.
I tried to find out example but i did not find any example.

  1. gameObject.GetComponent<UIWidget>().hitCheck = HitCheck;
  2.  
  3. bool HitCheck(Vector3 worldPosition)
  4. {
  5.         // Here what code to write to know whether a particular gameObject hit or not.         
  6. }

Thanks in advance.

 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to use UIWidget.HitCheck delegate in my program.
« Reply #1 on: November 12, 2014, 07:52:16 AM »
That's not what hit check is used for.

Hit check is to perform additional checking on the widget, for example sprite alpha sampling.

pawankumar113

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: How to use UIWidget.HitCheck delegate in my program.
« Reply #2 on: November 12, 2014, 08:04:24 AM »
So How can it detect which gameObject hit in NGUI such as RayCast used to detect that whether
gameObject hit or not. kindly guide me.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to use UIWidget.HitCheck delegate in my program.
« Reply #3 on: November 12, 2014, 08:07:10 AM »
Again, that's not what it's used for. Hit check is to do additional checking such as alpha. I am not sure how much more clear I can explain it.

Raycasting is done in UICamera.Raycast.

pawankumar113

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: How to use UIWidget.HitCheck delegate in my program.
« Reply #4 on: November 12, 2014, 08:47:08 AM »
Sorry but i was asking can i achieve this task by another way or method.
Bye the way i can use UICamera.lastHit

Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to use UIWidget.HitCheck delegate in my program.
« Reply #5 on: November 14, 2014, 04:24:36 AM »
NGUI's events always automatically go to the top-most widget. There is no need for any additional checks here. What is it are you trying to do, exactly?