Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by xenix2012 · Apr 15, 2016 at 09:05 AM · c#gameobjectsendmessage

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?

Comment
Add comment · Show 9
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image xenix2012 · Apr 15, 2016 at 11:27 AM 0
Share

bump, anyone?

avatar image Immanuel-Scholz · Apr 15, 2016 at 11:52 AM 0
Share

What message do they send? Can't you just rename the function in your code?

avatar image xenix2012 Immanuel-Scholz · Apr 15, 2016 at 12:08 PM 0
Share

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".

avatar image meat5000 ♦ xenix2012 · Apr 16, 2016 at 10:03 AM 1
Share

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.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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;
 
          ...
     }
 }
Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image xenix2012 · Apr 15, 2016 at 01:37 PM 0
Share

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.

avatar image Immanuel-Scholz xenix2012 · Apr 15, 2016 at 01:41 PM 0
Share

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.

avatar image xenix2012 Immanuel-Scholz · Apr 15, 2016 at 01:48 PM 0
Share

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.

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges