Search Issue Tracker
Won't Fix
Votes
0
Found in
2021.3.12f1
2022.1.21f1
2022.2.0b13
2023.1.0a17
2023.2.0a1
2023.3.0a3
6000.0.0b11
Issue ID
UUM-18067
Regression
No
Created materials specifically assigned to renderer.materials are cloned regardless when read back from renderer.materials
How to reproduce (simplified repro steps, see the original user report in the Comments for the original steps):
1. Open a new Scene
2. Create a Cube in the hierarchy
3. Attach "MaterialTestScript.cs" to the Cube
4. Create a Material asset in the project browser and name it "TestMaterial"
5. Drag the Material asset to the Material field of “Material Test” Script Component on the Cube
6. Enter Play Mode
7. Open the Settings of the "Material Test" Script Component in the Inspector (Three dots)
8. Press "Set Material"
9. Notice how the Material on the Renderer gets set to "TestMaterial"
10. Stay in Play Mode and again open the Settings of the "Material Test" Script Component
11. Press "Get Material"
Expected result: The Material on the Renderer does not change, it stays "TestMaterial"
Actual result: The Material on the Renderer changes to "TestMaterial (instance)"
Reproducible with: 2021.3.12f1, 2022.1.21f1, 2022.2.0b13, 2023.1.0a17, 2023.2, 2023.3
Couldn’t test with: 2020.3.41f1 (Script errors: “Tuple must contain at least two elements”)
Reproducible on: macOS Monterey 12.6 (Intel), Windows 10
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
- The LOD Group CrossFade Animate Cross-fading feature does not fade when the GPU Resident Drawer is enabled
- [Android Module] Unity double writes files in the "StreamingAssets" folder when they are deleted using "IPostGenerateGradleAndroidProject" after the Grandle project is generated
- IndexOutOfRangeException and InvalidOperationException when clicking on the HTML log in the Console
- Warnings "Attempting to draw with missing bindings" are logged when opening the HDRP VFX Template Sample Scene
- Red spots appear when Blending Lighting Scenarios using Adaptive Probe Volumes
Resolution Note:
This is expected behavior, you should use the sharedMaterial property to not instantiate a copy of the material
https://docs.unity3d.com/ScriptReference/Renderer-sharedMaterial.html