I have made a button prefab which has a boxcollider2d with it and a script which contain OnMouseUp method . It is working in menu and OnMouseUp is being called but in game scene it is not being called. I have no idea how same prefab can work in one scene and not in another.
OnMouseUp/Down/Over/Drag require a collider or a GUIElement, does your object have that ?
Try in update. First debug on mouse ButtonUp. This c# script name DebugOnMouseUp will hide your mouse arrow when left mouse button is press and debug if the mouse button is up. It will help you to debug your mouse button.
using UnityEngine;
using System.Collections;
public class DebugOnMouseUp : MonoBehaviour
{
void RightMouseWasPressed ()
{
Screen.lockCursor = true;// hide mouse arrow
}
void MyFunction ()
{
Debug.Log ("Left Mouse button up! " + "
");
Screen.lockCursor = false;// Show mouse arrow
}
// Update is called once per frame
void Update ()
{
if (Input.GetMouseButtonDown (0))
RightMouseWasPressed ();// Hide left mouse
if (Input.GetMouseButtonUp (0))
MyFunction (); // Show left mouse
}
}