I am trying to think of a nice way of putting: GetMouseDown(0) AND (KeyCode.LeftShift OR KeyCode.RightShift) The way I am writing it doesn’t feel optimised to me. Would you write your if statement this way, or use something different?
Anyway is fine, it won’t affect performance. Don’t think of nice ways to ‘put’ things, just do it. If you need to optimise, you do that after when you actually know you need to.
Thanks, I’ll use that then. Is there a way of stating I want shift, but I don’t care which shift it is?
I just tried:
if(Input.GetMouseButtonDown(0) && (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)))
I can’t quite see why this isn’t working. The code is fine (according to Unity), but I think I might have missed a bracket. Any ideas?
^ Nevermind, everything does work. I mistook my console.
If you are worried about typing this out over and over again, push it into a static helper method.
Actually this is very small compared to some if I have had to write in the past. It does look optimizes though because if the mouse button is false then the if statement will be skipped and the two shift checks are not evaluated.
For now I wouldn’t worry about how many CPU cycles this if takes because at this point it is a mute point.