Hello everyone,I made a simple scene:
When the mouse cursor on a box(It’s anchor),The mouse cursor will be hidden, while the mouse position display a GUI image.
But, my scene in the run-time,When the mouse cursor on a box (anchor) , it happened flicker, Why is this? How can I solve?
When the mouse moves over the cube, the OnMouseEnter function is called correctly and displays the box. However, the box is then displayed over the cube and so the mouse is deemed to be “in” the GUI box rather than the cube. The cube’s OnMouseExit function is called when this happens and the box is removed. And so on…
The solution is either to use a GUI control that doesn’t react to the mouse (such as a Label), or to use raycasting to detect the mouse entering the cube (see this thread for a code sample).
I have the same problem here but i’m using GUI.Label and Rect.Contains instead of OnMouseEnter.
The Label is correctly displayed (and don’t blink) but the mouse cursor continue to blink… When I print Screen.showCursor, it’s always false (when Label must be display). The others function who change Screen.showCursor are not called (tested with Debug.Log)…
Someone know what happens ?
For more informations, i’m trying to do a resizable box. So there’s the code
declarations
public Texture2D _resizeHorShape;
public Texture2D _resizeVerShape;
public Texture2D _resizeUpLeftShape;
public Texture2D _resizeUpRightShape;
private Texture2D _resizeShape;
in function Update
if (!Input.GetMouseButton(0)) {
// Vertical and Corners
// top
if (new Rect(m_boxRect.x, m_boxRect.y, m_boxRect.width, 5).Contains(mousepos)) {
if (mousepos.x < m_boxRect.x + 5)
_resizeShape = _resizeUpLeftShape;
else if (mousepos.x >= m_boxRect.x + m_boxRect.width - 5)
_resizeShape = _resizeUpRightShape;
else
_resizeShape = _resizeVerShape;
if (Screen.showCursor) Screen.showCursor = false;
// bottom
} else if (new Rect(m_boxRect.x, m_boxRect.y + m_boxRect.height - 5, m_boxRect.width, 5).Contains(mousepos)) {
if (mousepos.x < m_boxRect.x + 5)
_resizeShape = _resizeUpRightShape;
else if (mousepos.x >= m_boxRect.x + m_boxRect.width - 5)
_resizeShape = _resizeUpLeftShape;
else
_resizeShape = _resizeVerShape;
if (Screen.showCursor) Screen.showCursor = false;
}
// Horizontal
else if (new Rect(m_boxRect.x, m_boxRect.y, 5, m_boxRect.height).Contains(mousepos) ||
new Rect(m_boxRect.x + m_boxRect.width - 5, m_boxRect.y, 5, m_boxRect.height).Contains(mousepos)) {
_resizeShape = _resizeHorShape;
if (Screen.showCursor) Screen.showCursor = false;
// Normal Cursor
} else {
_resizeShape = null;
if (!Screen.showCursor) {
Screen.showCursor = true;
}
}
}