Search Issue Tracker
By Design
Votes
0
Found in
2018.4
2018.4.29f1
2021.1
Issue ID
1291755
Regression
No
ShaderUtil.CreateShader with invalid source causes Shader interactions to throw a warning/error until the Editor is restarted
How to reproduce:
1. Open the user's attached "New Unity Project (11).zip" project
2. Go to Testing -> Create Shader
3. Right-click on the "NewSurfaceShader" Asset in the Project window
4. Press the "Reimport" menu item
5. Observe the Console log
Expected result: No errors messages are thrown in the Console log
Actual result: "Shader error in '': Parse error: syntax error, unexpected $undefined, expecting TOK_SHADER at line 1" error message is thrown in the Console log
Reproducible with: 2018.4.29f1, 2019.4.14f1, 2020.1.13f1, 2020.2.0b11, 2021.1.0a5
Notes:
- The issue is also reproducible when creating a new Image Effect Shader, Unlit Shader, Standard Surface Shader
- The issue is not reproducible when creating a new Compute Shader, pressing "Refresh" on a specific Shader, or compiling a Shader's code
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Texture2D hash changes inside of an AssetBundle when rebuilding a SpriteAtlas bundle with an empty AssetPostprocessor Script enabled
- Aniso Level still applies when Generate MipMap is disabled in Texture Import Settings
- Mipmap Limit Groups long names are not truncated when creating a new Mipmap Limit Group with a long name
- “ArgumentException: Invalid double parameter.” error is thrown when Infinity is typed into the Fixed Timestep field
- GameObject becomes gray when using HDRP and STP together on macOS
Resolution Note (2021.1.X):
ShaderUtil.CreateShaderAsset() will create a shader object that, unless explicitly destroyed, will live in the editor session until the editor is shut down. Whenever some shaders are importer we atm reload all the shaders and log any existing errors in them. Now, the created shader had an error in it so it will appear in the console after any shader being imported. This all is expected although a bit awkward in this synthetic case where the shader is created without import context which makes the error message to be not so informative.