Hide reference to ProceduralMaterial.#663
Conversation
|
|
Editor/EditorCore/pb_ObjectArray.cs
Outdated
| #if UNITY_6000_6_OR_NEWER | ||
| if (array[i] is T) | ||
| { | ||
| arr[i] = (T)System.Convert.ChangeType(array[i], typeof(T)); |
There was a problem hiding this comment.
Using System.Convert.ChangeType for reference types (like Unity's Material, Mesh, or GameObject) will throw an InvalidCastException unless the runtime type of the object exactly matches T. It does not support casting through inheritance (for example, if array[i] is a MeshRenderer and T is Renderer).
Since the if (array[i] is T) check on line 33 already guarantees that the object is compatible with T, a direct cast is safer, more performant, and correctly handles inheritance as well as unboxing for value types.
| arr[i] = (T)System.Convert.ChangeType(array[i], typeof(T)); | |
| arr[i] = (T)array[i]; |
🤖 Helpful? 👍/👎
Codecov ReportAll modified and coverable lines are covered by tests ✅ @@ Coverage Diff @@
## master #663 +/- ##
==========================================
+ Coverage 36.05% 36.99% +0.93%
==========================================
Files 277 277
Lines 34909 35000 +91
==========================================
+ Hits 12588 12948 +360
+ Misses 22321 22052 -269
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Adding @modrimkus-unity to double check the change on MacOS |
|
@lopezt-unity Did a sanity check for the Material Editor, applying materials, etc. on MacOS and it looks good. |
DO NOT FORGET TO INCLUDE A CHANGELOG ENTRY
Purpose of this PR
bugfix/remove-proceduralmaterial-reference
Links
Jira: https://jira.unity3d.com/browse/UUM-138539
Comments to Reviewers