JetBrains / JetBrains/resharper-unity

Improve quick fix for introducing a cached property ID

Open
#1,829 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
C#
Stars
1.2k
Forks
142
PR merge metrics
No merged PRs in 30d

Description

The [`Material.SetFloat`](https://docs.unity3d.com/ScriptReference/Material.SetFloat.html) method can take a string name, that is immediately converted to a property ID via [`Shader.PropertyToID`](https://docs.unity3d.com/ScriptReference/Shader.PropertyToID.html). We already have an inspection and quick fix to recognise this and introduce a field with a converted property ID. We can make some improvements:

* When replacing one instance, check to see if there are any other instances in the same file and prompt to replace all.
* Check to see if a field already exists and change text to say something like "Use existing property field 'Whatever'"
* Provide name suggestions to choose from, based on the initial string literal value, but with additional suffixes, such as `PropId` and `ShaderPropertyId`

Contributor guide

Open the contributing guide

Research direction

Start from the existing inspection and quick fix that recognises Material.SetFloat string arguments and Shader.PropertyToID conversion. Trace how it introduces the cached field, then cover the three requested outcomes: prompting to replace other instances in the same file, reusing existing property fields, and offering suffix-based name suggestions.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.