UI window preventing OnMouseOver event on 3D Object

I have been working on this for a while now trying both raycast and OnMouseOver and i think i have missed a step somewhere along the way

I have a 3D model that is set to rotate. I am trying to say when the mouse is over the object (or a mesh collider) then stop rotating. However nothing i have tried in the last 3 hours has worked at all.

on my 3D model i have a mesh colider and a c# script called “rotate.cs”

using UnityEngine;
using System.Collections;

public class Rotate : MonoBehaviour {
	//private button = male;
	public bool rotate = true;


	void Start() {

	}

	void Update() {
		transform.position = new Vector3 (500, 0, 0);

		if (rotate == true) {
			transform.RotateAround (Vector3.one, Vector3.up, 20 * Time.deltaTime);
		} else {
			transform.RotateAround (Vector3.one, Vector3.up, 0);
		}
	}
	void OnMouseOver() {
		Debug.Log("Mouse Over");
		rotate = false;
	}
	void OnMouseExit() {
		Debug.Log("MouseOff");
		rotate = true;
	}
}

Can someone go through step by step on how to get this working with either raycast or OnMouseOver event systems.

I just tested your script on a standard cube in an empty scene, and it behaves really odd. The cube rotates slowly but flickers violently as the call which sets transform.position fights the rotations.

The OnMouseOver and OnMouseExit methods execute perfectly fine. I did a minor change to your script, so now it looks like this:

using UnityEngine;
using System.Collections;

public class Rotate : MonoBehaviour
{
    //private button = male;
    public bool rotate = true;
    
    void Start()
    {

    }

    void Update()
    {
        if (rotate == true)
        {
            transform.Rotate(Vector3.one, 20 * Time.deltaTime, Space.Self);
        }
    }
    void OnMouseOver()
    {
        Debug.Log("Mouse Over");
        rotate = false;
    }
    void OnMouseExit()
    {
        Debug.Log("MouseOff");
        rotate = true;
    }
}

Try that. It removes the flickering and behaves the way you describe. You can use that as a starting point to move forward, at least.