resharper-unity
resharper-unity copied to clipboard
Repeated property access could be improved with awareness of SetPositionAndRotation
The detection of:
transform.localPosition = Vector3.zero;
transform.localRotation = Quaternion.identity;
// Or
transform.position = Vector3.zero;
transform.rotation = Quaternion.identity;
And turning it into:
transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
// Or
transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity);
Would be a great way to help notify users that these combined APIs exist, instead of making their code grow by introducing a local variable when it may not be necessary.
(Do note that SetLocalPositionAndRotation
was introduced in 2021.3.11f1)
This (and many more) is already implemented by Microsoft's (UnityVS) Roslyn Analyzers: https://github.com/microsoft/Microsoft.Unity.Analyzers/blob/main/doc/UNT0022.md It's be great is those analyzers where shared between VS and Rider...