pointerEnter on a sphere, in a 2D project
I'll try not to look like a complete idiot on my first question but I am.
In my Unity 2D project, I've found the sphere to have the ideal circular shape I'd like to use for mouse/touch inputs for the game, however,
-The Sphere only appears in the scene editor, not the game. -The EventSystem does not highlight that the sphere has the mouse entered when the mouse is supposedly over the object. -In attempting to use the sphere as a child object, only the parent Image is highlighted (the only real use of the sphere is as a hitbox for various uses, dragging or rotating the image).
With all that said, here's my questions.
Why can't I see the sphere in the game view?
Is there a way to use the sphere as the UI hitbox I'm after, or is there a better way to get a circular hitbox?
Thanks for your time on this
Answer by TBruce · Apr 13, 2016 at 02:31 AM
@Bawnty I am not sure what you are looking to do. I also do not know why you are not able to see the sphere in your game view. Try resetting the transform of the sphere game object. Because there is a circular collider you can get clicks using the OnMouseDown() function
void OnMouseDown()
{
if (camera && Input.GetButtonDown("Fire1"))
{
Vector3 mousePos = camera.ScreenToWorldPoint(Input.mousePosition);
Debug.Log("Mosuse is located at Vector3(" + mousePos.x + ", " + mousePos.y + ", " + mousePos.z + ")");
}
}
I'm attempting to define a circular area the mouse/finger touch can fall into to perform an action,
if(Input. is within the circular area) { //perform desired action }
Having a sphere and using the pointerEnter property of EventSystem would seem to solve this?
I've also reset the transform of the sphere to no avail. An invisible sphere is ideal but I'd like to know why I can't see it
Your answer
Follow this Question
Related Questions
Dash through enemies and dont taking damage 3 Answers
Code does not execute move right after being in top left corner 0 Answers
CS1216 error 0 Answers