Skip to content

Hide reference to ProceduralMaterial.#663

Open
Thomasch-unity3d wants to merge 4 commits intomasterfrom
bugfix/remove-proceduralmaterial-reference
Open

Hide reference to ProceduralMaterial.#663
Thomasch-unity3d wants to merge 4 commits intomasterfrom
bugfix/remove-proceduralmaterial-reference

Conversation

@Thomasch-unity3d
Copy link
Copy Markdown

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

@cla-assistant-unity
Copy link
Copy Markdown

cla-assistant-unity bot commented Mar 31, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ lopezt-unity
❌ Thomasch-unity3d
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown

@u-pr u-pr bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May require changes

The review identified a potential runtime issue in pb_ObjectArray.cs where System.Convert.ChangeType is used improperly for reference types and inheritance. A direct cast is recommended for safety and performance.

🤖 Helpful? 👍/👎

#if UNITY_6000_6_OR_NEWER
if (array[i] is T)
{
arr[i] = (T)System.Convert.ChangeType(array[i], typeof(T));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high
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.

Suggested change
arr[i] = (T)System.Convert.ChangeType(array[i], typeof(T));
arr[i] = (T)array[i];

🤖 Helpful? 👍/👎

@codecov-github-com
Copy link
Copy Markdown

codecov-github-com bot commented Mar 31, 2026

Codecov Report

All 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     
Flag Coverage Δ
probuilder_MacOS_6000.0 35.59% <ø> (+1.01%) ⬆️
probuilder_MacOS_6000.3 35.59% <ø> (+1.01%) ⬆️
probuilder_MacOS_6000.4 35.59% <ø> (+1.01%) ⬆️
probuilder_MacOS_6000.5 35.59% <ø> (+1.02%) ⬆️
probuilder_MacOS_6000.6 35.59% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
Editor/EditorCore/MaterialEditor.cs 0.00% <ø> (ø)

... and 46 files with indirect coverage changes

ℹ️ Need help interpreting these results?

@lopezt-unity
Copy link
Copy Markdown
Collaborator

Adding @modrimkus-unity to double check the change on MacOS

@modrimkus-unity
Copy link
Copy Markdown
Contributor

@lopezt-unity Did a sanity check for the Material Editor, applying materials, etc. on MacOS and it looks good.

Copy link
Copy Markdown
Contributor

@modrimkus-unity modrimkus-unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants