When working in tight loops or performance-critical sections, remember that scalar math is faster than vector math.
Therefore, whenever commutative or associative arithmetic allows, attempt to minimize the cost of individual mathematical operations.
You can see here, the related documentation on the Unity website.
using UnityEngine;
class Camera : MonoBehaviour
{
public void Compute()
{
Vector3 x;
float a, b;
Vector3 slow = a * x * b;
}
}Re-order operands for better performance:
using UnityEngine;
class Camera : MonoBehaviour
{
public void Compute()
{
Vector3 x;
float a, b;
Vector3 fast = a * b * x;
}
}A code fix is offered for this diagnostic to automatically apply this change.