Search Issue Tracker
Fixed
Votes
1
Found in
4.5.4f1
Issue ID
640365
Regression
No
Calling anything from renderer.material on a prefab breaks the prefab material
Setting Material.shader (or anything else) on a prefab during runtime causes the prefab to get changed after leaving play mode. During play mode the field says "Type Mismatch" while after leaving play mode it says "Missing (Material)"
To reproduce:
1. Import repro package
2. Open scene repro
3. Inspect the two prefabs, notice that their materials are fine
4. Enter play mode and inspect the prefabs again - the materials are set to "Type Mismatch"
5. Leave play mode - the materials are now missing
It should return the prefabs back to normal
Solution: Use renderer.sharedMaterial instead.
Comments (2)
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
- There is no way to adjust the HDR Paper White value of the Unity Editor's interface, making it difficult/uncomfortable for some developers to work on very dark/bright scenes in HDR
- Animator window has a dropdown button that throws “MissingReferenceException” error on a new project when the previous project had a GameObject with an animation
- Animator State name overflows outside the visual box when the State has a long name
- UI Document file remains marked as Dirty after Undoing made changes
- Switching between UI Documents with different Canvas sizes marks the UXML file as dirty
greedygoblins
Mar 01, 2015 11:03
... also... I only need to 'read' the prefab.renderer.material without changing anything, for this issue to occur.
e.g. var x = prefab.renderer.material;
will cause the prefab to lose its material?!!?
greedygoblins
Mar 01, 2015 11:00
I too get this issue when trying to change the material on an instance of a GameObject created from a prefab. It somehow causes the prefab material to change to "Type mismatch" during run time and then become "Missing" when the game is stopped.