Unity QuickTip: Math in Input Field
You may already know that you can make simple calculations inside each numeric input field in the Unity editor like so:
But when selecting multiple objects there is a catch. What you ultimately do is overriding a single value for all of them. But what if you want to relatively change a value? Well then there are two options: Either use a relative operator or the variable v, which stands for the current value.
The cool thing is that next to simple math there are a few functions that you can use as it is documented here.
Weirdly, this v variable doesn't even seem to be documented anywhere, but it has some additional power within these methods.
Workflow improvement
Notice that these methods and multi-editing works for EVERY numeric input field, not only Transforms! This can turn out to be beneficial for your workflow where multi-selection is allowed. Do you want to add the damage value of all your selected weapons then simply use += 2 or v + 2.
Available Functions
Unity offers two special methods:
L(a, b): Results in a linear distribution from a to b (including).
R(a, b): Results in a random distribution from a to b (including).
Next to those I have identified the following functions:
floor, round and ceil
sin, cos and tan
For exponents you can use sqrt and the ^ operator like 3^2
A known variable next to v is pi.
With L() it is possible to linearly position elements.
Can I make a Grid?
Ordering things in a grid, however, becomes more complicated and probalby you want to use custom tools for that. Also the concrete order which the operations choose the elements is sometimes unpredictable. But here is an example:
X: ((L(0,8)%3)-1)*-1.12
Y: floor(L(0,2.99)-1)*1.12
Doing this manually might be quicker than figuring out that math, but hey it works. If I find more useful stuff then I'll update it here.