StrangeLoopGames / EcoIssues

131 stars 21 forks source link

Audio release mode problems #20748

Open johnkslg opened 3 years ago

johnkslg commented 3 years ago

I think most of the problems with sound are in the AmbienceController [3:02 PM] Joe: It has 2 problems: 1. It checks for null on the "audio" game object, but nothing will assign it to null. This is a very confusing one actually, because Unity does something pretty stupid: In debug/editor builds it has some kind of weak reference system for GameObjects, so when they get removed any reference to them becomes null. But in a release build, or IL2CPP builds (apparently) it doesn't do this anymore. So in this case when you test in debug you get lots of Ambience sounds, far more than you get in the release build. As in the release version "audio" reference used in the class never becomes null. So it only plays the sound once.

[3:05 PM] Joe: The second problem is that it is just spawing prefabs, not using any pooling, and sometimes those prefabs are setup wrong: eg InsectFX one. Thus leading to the growing number of insect game objects slowly decaying frame rate. I think this decay was probably slow in release because of the first issue I mentioned. So it might take a few hours of play to build up the objects.

[3:15 PM] Joe: Here is some more info on it: https://blogs.unity3d.com/2014/05/16/custom-operator-should-we-keep-it/

OnlyJoe33 commented 3 years ago

I think it must do this check in release builds as well, or it would cause no end of issues (that comment was just based on reading a forum). But it is a very strange design choice that unity made doing this. (Which is why Lists and HashTables can look like they have null elements in them, when in actual fact they have an object that pretends to be "null")