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
- Mono Windows Builds don't produce full log callstacks when generating logs
- AssetBundles fail to load when running in Built Players for Mobile Devices
- UI elements with text gets bigger and grey when Player window is moved to another screen with different resolution
- System name accepts multiline text but crops it on confirmation, duplicates input, and shrinks the field when empty
- UI element scale and position are wrong in project build when DRS is changed with HDR and Software Dynamic Resolution enabled
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