How to call all methods of specific name ?
Hi all. If i create public method with specific name (like OnPlayerFinalyDie), is here some way how to call all of them at same time without reference to objects ?
-Garrom
Answer by UnityCoach · Jan 19, 2017 at 02:28 PM
You could use a C# Interface that implements the method signature, then collect all classes that implement that interface and safely call the method on them.
Otherwise, you can use GameObject.SendMessage ("MethodName") on all game objects, it's also "safe" if you don't require a receiver, but performance wise, not recommended.
An intermediate implementation would be to have a "manager" that collects all objects of types known to implement that method, and use it to "broadcast" the message.
Your answer
![](https://koobas.hobune.stream/wayback/20220612105142im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Use Features in a plugin from another plugin 0 Answers
How to use only 1 method for 2 objects which different class type 0 Answers
Following round planet tutorial, line of code not working? 2 Answers
Function won't be called 1 Answer
The laser problems 0 Answers