CharacterShadow + broken OnMouseDown()

Hello!

I use CharacterShadow script from wiki (it creates a cam and a projector, render an outline of an object, and projects it to create a shadow which works on low end machines).

And, well, the problem is that OnMouseDown() stops working when I use the script (I suppose that’s because a cam is created and it is located in the same place as MainCamera).

One solution is to stop using this script, the other one - to write my own OnMouseDown() implementation. Is there any third one?

thanks

Did you create the second camera by duplicating the main camera? If so, it is likely that it has the Main Camera tag (this is what actually identifies the camera as the main one). Try setting that tag to something else for the shadow camera.

I’ve noticed that OnMouseDown() doesn’t work in lower left part of the screen.

I’ve attached an example project with test case.

Try clicking in “lower left” part of the screen and you won’t see any messages about successful click in the console.

Any insight into the problem would be most helpful!

thanks :slight_smile:

397916–13658–$ShadowBugTest.zip (66.7 KB)

Please, set game vieport size to 1024x768.
I’ve also attached a screenshot showing where to click to see the bug in action.

397948--13660--$shadowbug.jpg

Hehe.
The following code solves the problem:

void Update()
{
child.camera.rect = new Rect(0f, 0f, 1f, 1f);
}

public void OnPostRender()
{
…
child.camera.rect = new Rect(0.999f, 0.999f, 0.001f, 0.001f);
}

Here we “spoil” the camera just before rendering ended, on the next game engine life cycle OnMouseDown is called, then in Update() we “fix” the camera so the shadow is rendered OK.