OnPointerExit failing to call when parent object is scaled?

Updated on June 13, 2017 in [A] GUI
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
6 on June 13, 2017

Hey folks.
I’ve been working like a mad man on a new game, and ran into a snag, where I can’t seem to find any similarly answered questions to my issue I seem to be having. So I’m hoping someone here has a sharp eye/mind and can throw me a bone.
 
My issue is this. (I’ll try to keep it simple)
I have an image (call it ImageObject) with a script running OnPointerEnter() and OnPointerExit(). This image is a child of a parent object (call it parentObject).
When parentObject is scaled to Vector.One, things work great. OnPointerEnter() and OnPointerExit() work exactly as they should, doing things whenever the cursor starts hovering over the imageObject, and stops hovering over the imageObject.
 
However, when parentObject is scaled up to (Vector.One * 1.3f), then OnPointerEnter() works just perfectly, calling OnPointerEnter() when cursor starts hovering over the imageObject, but OnPointerExit() doesn’t get called when the cursor leaves the imageObject. It does get called however, after the cursor is far away from the imageObject and the cursor gets wiggled back and forth in multiple directions.
 
Any ideas, comrades? What’s happening here, and how might I fix OnPointerExit?
 
 
edit:
https://gfycat.com/WellwornUltimateBluemorphobutterfly
GIF added for visible understanding:
see comment below for accompanied explanation.

  • Liked by
Reply
2 on June 13, 2017
Devoted
on June 13, 2017

Yep, and I’ve checked those out already. Unfortunately, it doesn’t seem to lead to anything but a dead end.
 
the imageObject IS a UI element, on an emptyGameObject, parentObject, which is on the Canvas…
And all things work well when parentObject is scaled to Vector3.One

But when parentObject gets scaled just a bit bigger, it’s as if it just can’t easily detect when pointer leaves the bounds of the imageObject anymore…

Guru
on June 13, 2017

So why not actually change the size of the recttransform? That the recommended way for UI anyways

Show more replies
  • Liked by
Reply
Cancel
0 on June 13, 2017

Well, because the parentObject has 20 other child images on it which should all scale appropriately as well, based on the parentObject size.
I can provide a video/gif link too if you give me a minute…
Thanks for bouncing ideas off this though, Dion! Keep em coming.

  • Liked by
Reply
Cancel
1 on June 13, 2017

So the cursor is invisible in my GIF, but you can still interpret where it is, based on how much movement is produced by a resulting prefab:
https://gfycat.com/WellwornUltimateBluemorphobutterfly

Devoted
on June 13, 2017

the imageObject is the little green slash you can see just above the full card,
While the full card you see is a composite of all the different UI Images on the parentObject.
So, when the cursor hovers onto the green slash (aka imageObject), then the OnPointerEnter() handler is called, instantiating a separate card prefab; and when the cursor leaves the green slash (imageObject), the OnPointerExit() handler should be called, then the preview prefab is destroyed.
You can see in the GIF that the OnPointerExit() works correctly when the parentObject is scaled to Vector.One, but not when it’s a larger size, like my employer wants it to be.

 

Show more replies
  • Liked by
Reply
Cancel