Skip to content

Avoid using string based names for setting and getting properties on Animators, Shaders and Materials

Vladimir edited this page Dec 18, 2018 · 4 revisions

The string methods simply perform string hashing and then forward the hashed ID to the integer-valued methods. Whenever using a Set or Get method on an Animator, Material or Shader, use the integer-valued method instead of the string-valued methods. The property IDs created from string hashes are deterministic over the course of a single run.

This inspection will highlight any Set or Get functions using the string parameter as name for Animator, Shader and Material and provide quick fix (Alt+Enter) which will declare (or reuse) a static read-only integer variable for property name, and use the integer variable in place of the string.

History:

  • This inspection was first added in Rider/ReSharper 2018.3
Clone this wiki locally