Problem with Input.GetMouseButtonDown? weird bug. C#

This is very odd!

I have a code block that looks like this:

if (Input.GetMouseButtonDown(0))
{
  DoSomething();

  int value = 0;
}

It’s in the Update() function of a script attached to a prefab.

If I create a copy of the prefab at runtime. There’s no problem. DoSomething is called when the mouse is clicked.

If I have a prefab in the scene, click play, then step through in the debugger and click on the mouse, I can see that the execution steps into the block but DoSomething is not called and execution falls through to “int value = 0;”

The code then continues as expected. No exceptions are thrown. Nothing seems amiss.

Anyone know why this might be happening?

(if I replace Input.GetMouseButtonDown with any other true statement then DoSomething is called fine)

I have found that if

I have found weird issue, if scene has no camera tagged “MainCamera” (so Camera.main is always null) my mouse events doesn’t work at all.