Ordering of And and Or in If Statement

This is a little confusing, but if I have a statement, for example:

if (boolean1 && boolean2 || boolean3)
       //Some code

Will this run if boolean1 and boolean3 are true, but boolean2 isn’t? I need to know about the ordering of ands and ors in an if statement, so if I have an and followed by an or, will unity use the whole first statement, or just the part after the and. Thanks! <3

Well, just have a look at the operator precedence in the C# language. Operators higher up in the list take precedence while those further down are evaluated later. Operators in the same group are most the time evaluated left to right, but some operators are right to left.

As you can see the conditional AND operator has a higher priority than the conditional OR. So your code would be evaluated like this

if ((boolean1 && boolean2) || boolean3)

The order in which you arrange your conditions do not really matter. So doing

if (boolean3 || boolean1 && boolean2)

would result in the same outcome since this is evaluated like this

if (boolean3 || (boolean1 && boolean2))