- Home /
Block GameObject from reciving SendMessage
Hi all, I have a problem: one of dll's which I use sends SendMessage to all objects on scene when my player is destroyed. I cant decompile dll and I cant change dll. So, is there posibility to "mark" GameObject as no-SendMessage GameObject or sth like that?
What message do they send? Can't you just rename the function in your code?
I cant, but even if i could it gives nothing - dll still sends this message to all object, it doesnt matter if there is this function in any of object on scene. I'm looking for exactly what I wrote - "posibility to "mark" GameObject as no-Send$$anonymous$$essage GameObject or sth like that".
Possible additions You can add a easily add area of interest and line of sight functionality (i.e. only send updates if that object is in range) by using the NetworkView.SetScope method and setting scope of NetworkPlayers to each view by using circles to filter data even more and also could create each group in another space as noted before. You can also make the GameSession$$anonymous$$anager a singleton. The feature can also be integrated with uZone to instantiate new servers when a server is full and add servers to uLobby and make things automatic. Delegates also can be changed and ins$$anonymous$$d of events one could use Send$$anonymous$$essage or reflection for a more uLink like event registration and an easier workflow.
Its from the website. It suggests that you get the option to not use Send$$anonymous$$essage.
Answer by Immanuel-Scholz · Apr 15, 2016 at 12:14 PM
The only way is to set the GameObject to inactive ( gameObject.SetActive(false);
) but then, a lot more things get deactivated as well (i.e. rendering, Update calls, collisions etc..)
However, if you control the source of the script that is receiving the messages, you can just add your own "shouldThisBeHandled" flag into your components or rename the function (if you never want this to be called).
For example:
class Foo : MonoBehaviour
{
// set this to false for all objects you don't like the SendMessage
public bool shouldNastyMessageBeHandled = true;
// this is called from some external DLL
void MyMessageCallback()
{
if (!shouldNastyMessageBeHandled) return;
...
}
}
In general you're right about both things but it cant help me (but it can help most of the people with this problem)
Explanation: I cant set GO inactive because of resons u presented. 2nd - I can "override" this method in reciver but it doesnt matter - I have over 100k objects on scene and EACH of those recive Send$$anonymous$$essage, there is no diffrence if object has this method or not - if it inherits from $$anonymous$$onoBehaviour it will recive it.
I don't see why you can't change the receiving message and add the early return.
Or is it about performance? Then you are out of luck in any way already. Even trying to send a message to 100k objects will take too long, no matter whether they have the receiving function or not. You need a different external plugin.
That's what I was afraid of :( Yes, problem is about performance and trying to sendmessage. The best thing would be sth like 1 object who recive message at the begining of sending and "magically" stops sending it further. This object should have event "CallNasty$$anonymous$$essage" and all object which rly needs to know about it can add themselves to this event.
Your answer
Follow this Question
Related Questions
Getting nullreference error while using sendmessage 1 Answer
Triggers and SendMessages. C# 2 Answers
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
c# destroy gameobject on 0 hp 2 Answers