Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
2
Question by nshgraph · Mar 28, 2011 at 01:58 AM · sendmessagebroadcastmessage

Passing 'null' as parameter to SendMessage/BroadcastMessage

Is it not possible to use null as the parameter for SendMessage/BroadcastMessage?

When I try to pass null I get the error 'Failed to call function SetSelectedNode of class PLC_Base. Calling function SetSelectedNode with no parameters but the function requires 1'

The use case is the situation where I am selecting a node from a set of nodes and the parameter is the GameObject of the node to be selected. Passing null should result in no node being selected.

I know there are a number of workarounds: - passing a dummy value that is no node's gameObject instead of null - overloading SetSelectedNode such that SetSelectedNode() calls SetSelectedNode(null) - passing an object with one field, that being the node to be selected

But these are all subpar compared to being able to use SendMessage/BroadcastMessage properly.

Comment
Add comment · Show 1
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 Fattie · Jul 05, 2015 at 08:42 AM 0
Share

Good question...........

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Fattie · Jul 05, 2015 at 08:49 AM

It looks like you simply cannot send "null" as a parameter.

Example,

http://forum.unity3d.com/threads/sendmessage-will-null-as-value-method-not.66756/

It's really silly - but there it is.

Comment
Add comment · 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
0

Answer by Justin Warner · Mar 28, 2011 at 02:12 AM

If sending a string, send "". It's = to null... If you're passing a number, pass a negative number, and check it in the place where the number is accepted and handle it accordingly... Same with other datatypes... Good luck!

Comment
Add comment · Show 3 · 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 nshgraph · Mar 29, 2011 at 03:23 AM 0
Share

Unfortunately it is an object reference, so the only proper value in this situation really is null. Sending through the empty string or a negative number just results in errors...

avatar image Justin Warner · Mar 29, 2011 at 12:18 PM 0
Share

Can you send over an empty gameobject? Then the user wont see it, and it'll just choose that one, you know?

avatar image nshgraph · Mar 29, 2011 at 09:58 PM 0
Share

That does seem better than the other workarounds I have, thanks.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

BroadcastMessage from one Object to another ? 1 Answer

Sending and Receiving Messages globally with BroadcastMessage / SendMessage 4 Answers

SendMessage is running before Start 1 Answer

SendMessage and BroadcastMessage not getting received outside the script. 0 Answers

How can I Broadcast a message on a GameObject and also send the message Upwards natively without sending twice the message on the target base object? 0 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