Is there a limited number of UnityEvent listeners I can have?

Hi all,

I’ve noticed something a bit odd in my game. I have a tilemap with a material linked to a shader which performs snow coverage, achieved by passing float parameter between 0 and 1 (most coverage).

In my controller script attached to the tilemap, I have a bit of code which checks the weather state to see if its snowing. If it is, then the scripts sets the coverage to maximum (instance snow coverage). This routine is in the Start method of my monobehaviour script, so that full snow coverage is set if you transition between scenes. However, this adds around 800 listeners to my weather manager monobehaviour script. In the editor, things work fine, instant coverage. But, in a production build, it doesn’t work. After inspecting code and whatnot I can only think the reason is some trimming of the list of listeners - perhaps garbage collections, or there is some internally set Capacity limit on the number of listeners in Unity’s Engine (the list which is added to via AddListener). Can anyone advise what is happening?

My next plan is to do away with the listeners, but I like having inversion of control without iteratively setting the snow coverage per tile in the tilemap myself.

EDIT: I removed the listener and in my manager class set the script on relevant objects to be covered in snow, setting the shader variable to 1 and works. It does seem like a listener problem

Differences in editor and build are likely an order of execution issue. Maybe you should differentiating when things happen with Awake/Start/OnEnable?