- Home /
Click handling at world scene level
I have a script attached to certain objects which when clicked sets a flag to true, now the problem is I need to be able to click anywhere else in the scene (no objects) to reset the flag.
Based off previous questions around scene level scripts, it was mentioned that I should just make an empty game object if I wanted to apply a script at scene level, but as these empty objects have no mass and are just containers, im at a bit of a loss...
I was thinking of maybe trying to have a click event script bound to the camera, but I am not sure if that would just overwrite the original click to the other objects which set the flag.
So is there any way to handle generic scene interaction events via script?
Answer by Piflik · Jul 26, 2012 at 06:33 PM
Make one singel script for all the clicks. Test if you hit one of the objects you want to hit (raycast + LayerMask), if not, reset the flag.
How exactly do you get one central way to test, I tried making an empty gameobject and attaching a script with On$$anonymous$$ouseDown, but as the object is non-existant in the game view you cannot click on it, so how do you go about making the one object to manage all the clicks? I have also tried doing an Update with a check for mouse down, but feels hacky...
Your answer
Follow this Question
Related Questions
C# moveOnMouseClick Rotation 2 Answers
Unity 3d(Space) Questions 1 Answer
Scene changing 1 Answer
How to Set a bool to Individual Scenes (C#) 1 Answer
Fading To New Scene Problem? 1 Answer