Set Materials Array Size from Editor Script

Does anyone know if you can set a MeshRenderer > Materials > Array Size from script? My end goal is to be able to empty the array by setting the size to 0 like so:

7877329--1001692--upload_2022-2-7_16-12-40.png

I believe you just make a new array of the desired size and assign it in.

Don’t forget to either Undo.RecordObject() or SetDirty it so it gets saved!

gah, thanks. so simple. I was trying to clear the array >_<

1 Like

Oh that only makes them angry.

As always, C# arrays are immutable in size. What is held in each cell can obviously change though.