Search Unity

[SOLVED] What's is the difference between these functions?

Discussion in 'Scripting' started by Deleted User, Dec 18, 2014.

  1. Deleted User

    Deleted User

    Guest

    Component.SendMessage
    GameObject.SendMessage
    Component.BroadcastMessage
    GameObject.BroadcastMessage

    They all seem similar from reading the API.
     
  2. Sbizz

    Sbizz

    Joined:
    Oct 2, 2014
    Posts:
    250
    One need to get the "gameObject" active and the other must have the component active.
     
  3. Deleted User

    Deleted User

    Guest

    OK but what about between send and broadcast?
     
  4. Sbizz

    Sbizz

    Joined:
    Oct 2, 2014
    Posts:
    250
    It doesn't give a ... if the gameObject / component is active ? :p

    (I'm not sure but this is the only difference SendMessage and BroadcastMessage)
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Mycroft and Deleted User like this.
  6. Deleted User

    Deleted User

    Guest

    Thanks I missed that last part.
     
  7. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Just for clarification there is no difference between Component.SendMessage and GameObject.SendMessage. Use which ever one is most convenient in your code.

    Component.SendMessage is the same as Component.gameObject.SendMessage.