Welcome,
Guest
. Please
login
or
register
.
December 11, 2023, 07:35:26 AM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
How to detect objected being hovered over while Dragging
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to detect objected being hovered over while Dragging (Read 1818 times)
LiveWire
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 8
How to detect objected being hovered over while Dragging
«
on:
August 23, 2013, 02:06:07 AM »
I'm trying to write a script that will cause an icon that I am dragging to change colour if it hovers over certain types of objects in the world.
I understand that UICamera.currentTouch.current will get me the object that is currently being hovered over while dragging. However, I don't know how to access this variable.
It is static, and I cant seem to access it by something like:
gameObject.GetComponent<UICamera>().currentTouch.current
and if I try this I get a null reference exception:
print(UICamera.currentTouch.current.name)
So my question is simple. How do I use this?
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: How to detect objected being hovered over while Dragging
«
Reply #1 on:
August 23, 2013, 02:39:12 PM »
It's only valid during NGUI callbacks such as OnPress, OnClick, etc. Instead of doing what you're doing, attach a script to your object you want to change color and implement the OnHover function inside.
Logged
LiveWire
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 8
Re: How to detect objected being hovered over while Dragging
«
Reply #2 on:
August 23, 2013, 11:40:50 PM »
Thanks ArenMook, I had a little trouble figuring out what to put the script on (I'm clicking one icon to start the drag but telling it with the UIDragObject script to drag a different object. So I had to put the script on the clicked object and have it change the colour of the dragged object), but it's all working now. Much appreciated!
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
How to detect objected being hovered over while Dragging