JetBrains / JetBrains/resharper-unity

Repeated property access could be improved with awareness of SetPositionAndRotation

Open
#2,413 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.2k
Forks
142
PR merge metrics
No merged PRs in 30d

Description

The detection of:
```cs
transform.localPosition = Vector3.zero;
transform.localRotation = Quaternion.identity;
// Or
transform.position = Vector3.zero;
transform.rotation = Quaternion.identity;
```
And turning it into:
```cs
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)

Contributor guide

Open the contributing guide

Research direction

Start by locating the existing Unity analyzer detection for repeated transform position and rotation assignments; no source file or test entry point is named in the issue. Verify the detection recognizes both local and world forms and reports the corresponding combined API, including the stated Unity version constraint.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, unity
Domain
game-dev, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.