It is inefficient to check Camera.main as this searches every object in the scene for a string comparison. Reduced to a single check
Camera.main can return null while the scene is shutting down
In older versions of Unity, that's correct. In newer versions, Camera.main uses a cached lookup, so it's not inefficient. (Similarly, a GameObject's transform property is no longer inefficient.)
However, you are absolutely correct about doing a null check. I'll add that. Thank you.
Thanks for taking this fix. Unity 2020.2 makes this optimization. It's still in beta as of the time of this posting, by our standards meaning it's still in alpha.
We internally subtract 1 from Unity's official version.
Alpha = Prealpha
Beta = Alpha
Normal release = Beta
Long Term Support = Normal release
I agree with you. I don't prefer to use Camera.main directly, but there are some projects that change cameras mid-scene. If we cache it in Start(), it may not be the correct Camera.main every time Update() runs. But that's why the method is virtual, so you can override it in a subclass if you want to cache Camera.main.
Thank you again for pointing out any issues like this, or the question you have about text auto-scrolling. I really appreciate it, as your feedback helps improve the Dialogue System for everyone.