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
- Popup windows spawn on the incorrect monitor when the Editor is placed near the boundary of scaled monitor next to a monitor with different scaling
- Hidden Tabs do not shift into empty space after closing visible Tabs
- [Android] Application not deployed on a device when "activity-alias" is used in the AndroidManifest
- Shader compile process adds shader ID to the constant buffer name when the word "Globals" is being used in Vulkan
- Audio Mixer Snapshot link to the documentation isn’t working
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