Fix Obsolete ShaderUtil usage in LODGenerator for Unity 2021.2+#74
Conversation
|
Additional clarification: • I checked the upstream issue tracker, and there is currently no open or closed issue related to the obsolete ShaderUtil API or Unity 2021.2+ compatibility. This appears to be a new problem affecting newer Unity installations. • This change is fully backwards-compatible — older Unity versions fall back to ShaderUtil via conditional compilation, while Unity 2021.2+ uses Shader.GetPropertyCount / GetPropertyType / GetPropertyName. • The Codacy “complexity +85” warning is based on the entire LODGenerator.cs file (which is already large and complex in its existing design). The edit itself does not materially increase complexity — the update replaces obsolete calls while keeping logic identical. This PR therefore only modernizes the API usage and prevents warnings (and potential runtime issues) in supported Unity versions without altering functionality. |
|
Hi @Abhilash1205, thank you for your contribution. |
Whinarn
left a comment
There was a problem hiding this comment.
LGTM, thank you for your contribution 👍
## [3.1.1](v3.1.0...v3.1.1) (2026-01-07) ### Bug Fixes * **lods:** fix obsolete ShaderUtil usage in LODGenerator for Unity 2021.2+ ([#74](#74)) ([314eeb2](314eeb2))
|
🎉 This PR is included in version 3.1.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Description:
This pull request fixes the obsolete ShaderUtil warnings in LODGenerator.cs when using Unity 2021.2 or newer.
Changes:
Replaced ShaderUtil.GetPropertyCount(shader) with Shader.GetPropertyCount() for Unity 2021.2+.
Replaced ShaderUtil.GetPropertyType(shader, index) with Shader.GetPropertyType(index).
Updated ShaderPropertyType.TexEnv to ShaderPropertyType.Texture.
Replaced ShaderUtil.GetPropertyName(shader, index) with Shader.GetPropertyName(index).
Preserved backward compatibility with Unity versions older than 2021.2 using preprocessor directives.
Fixed warnings: CS0618 (obsolete ShaderUtil usage).
Motivation:
These changes remove compiler warnings for newer Unity versions while maintaining compatibility with older versions.
Notes:
No functional changes were made to the logic of LOD generation.
The changes only affect editor-only asset destruction in DestroyLODMaterialAsset().
Closes:
N/A (or you can link any related issue if there’s one)