Trouble with OnMouseEnter Box Collider!

Everyone,

I am a bit new to Unity, but I think there is something broken with events and colliders in the Iphone release!

Here’s what I am trying to do:

Manually create a simple cube with a box collider, a camera, and a directional light…

Box Collider is set to a scale of 1.1,1.1,1.1 (a little bigger than the cube). IsTrigger = Off,

Attach a C# script (DetectMouseEnter) with

using UnityEngine;
using System.Collections;

public class DetectMouseEnter : MonoBehaviour {

void OnMouseEnter()
{
Debug.Log(“OnMouseEnter…”);
}

}


I NEVER GET an OnMouseEnter Event!!!

This SAME scene works just fine under standard Unity (2.1.0f5 (16146))… BUT NOT with the iPhone 1.0.1.f3 (19262)!!!

Any ideas? Anyone else seeing this? Help…

Regards,

Chris Aiken
Aiken Development LLC

This will not work.
There is no mouse enter as the mouse is only dragged.

you must use raycasts at the mouse position to see if you are over a 3D object or not.

there is a thread on that which includes a working script I think

Thanks for the information, I will search the forums for the thread.

Are there any examples in the documentation of this?

Seems strange that this does not work the same… I am surprised that this is the condition…

For example, in standard Unity, I just verified. If I start somewhere on the screen away from the cube box collider, click the mouse and DRAG the mouse into the collider, I see an OnMouseEnter event.

So, why would this be different on the iPhone? Even if the touchscreen is equivalent to a DRAG, then should this not work consistently across platforms?

Unity Support? Can you give us a reason/explanation?

Thanks again!

Chris Aiken
Aiken Development

No sure idea

But my guess is that the performance would die if you tried it as the move happens 60 times as second and running the onmouseenter 60 times a second sounds like a great way to be on 1 FPS without anything else …

The iphone is 10-30times weaker than your pc / mac, always keep that in mind.
for that reason, poly colliders are to be avoided whereever possible, for example.

dreamora,

Thanks for the help. I dug around the forums for the examples, and I have it working (crudely) using Physics.Raycast.

Regarding performance, this might be the case, but if you really need to detect the mouse/collider, then looks like you would have to do the same amount of work in the update function anyway.

I am thinking to create a script to emulate the standard behaviors. Maybe make these do the Raycasts when the Input.mousePosition changes.

Also use the “isTrigger” property of the collider to send messages OnMouseEnter/OnMouseExit (have to think over up/down) or OnTriggerEnter/OnTriggerStay/OnTriggerExit, accordingly.

If I get something clean, I will post this up for all to look at and reuse.

Thanks again for the help!

Regards,

Chris Aiken