I create Material programmatically and Unity crashes on iPhone with NullReferenceException in constructor (the arguments are not null - I’ve cheked this). Everything works fine in Editor though. Is there a limitation or it’s just a bug?
Hey there justonce, I’m experiencing a not so similar issue. But nevertheless, the same painstaking fact that mine also works in the editor, but fails randomly during device testing.
In my case, its when loading or making “active” already loaded (but, obviously, inactive) objects with different materials. Sometimes, it also crashes when creating referenced materials.
I’m still investigating our case, and would like to see if we are experiencing the same issue. Do you have crash logs or snippets of device logs that point to the crash?
It seems like the problem is solved by moving the material shader to the Resources folder.
Obviously if you’re dynamically loading something it will need to be in Resources or an Asset Bundle.