“You tried to refute how something performs on one platform by referring to how it performs on another? That’s not how this works.”
Yes… if I would have refuted anything, you would be right.
I was wondering whether Tim C did any real benchmark or just assumed that multicast delegates must be at least as performant as any other self-made solution (which is a very solid assumption, by the way).
His hint about “potentially change it in the future” seems to me that the current implementation is rather an “we keep it as easy and close as possible to Action, and extend it from there - at least we don’t do anything worse.”
Anyway, the topic here was about guarantee of order of callbacks. Unity seems to not really care about whether they should guarantee anything about order of calls (“you can’t rely on the order. … It seems like its order dependend … but may change…”)
In most of the games and programms I worked on, problems with the order of callbacks came up as a medium to major headache at least half a dozend times during development. Or at least we could solve a problem by solving some orders of callbacks around, especially during setup and shutdown of things (like zone loading, map restarts, savegames etc)
Most problems come from places, where people thought (or did some quick tests and assumed) that orders are stable, but then it turned out that they got messed around (e.g. after loading savegames, the order of registered listeners changed…)
As it is now, the UnityEvent does provide exactly one single service on top of a plain Action field: You can drag’n’drop some stuff in the editor. In my opinion, game engines benefit a lot from powerful callback systems and neither UnityEvent nor SendMessage is anything close to provide the set of features that are needed.
On another note… TimC: What makes you think the order of an C# multicast delegate is not guaranteed? Delegate.Combine guarantees to concat the lists and Delegate.Invoke guarantees to sequential call the list. So if you don’t mess around with the invocation list by yourself, the order IS guaranteed by .NET itself. Of course, as I said: If you don’t want people to depend on the order, you should clearly state this intention in the documentation. This way you can implement some mean stuff later that might be potentionally some nano-seconds faster in some places :p. At the cost of usability of UnityEvent…
PPS: Just looked into Mono source code. They combine delegates by a linked lists iteration and invoke by stack-calling from a backpointer. So for whats worth it: Don’t use UnityEvent with very large number of callback registrations or you might run into stack overflows and degrading performance of Add/Removes.