Exemplo n.º 1
0
   public void SendCustomEvent(
      [FriendlyName("Event Name", "The string-based event name.")]
      string EventName,
      
      [FriendlyName("Event Value", "The value to pass in the event.")]
      Vector2 EventValue,
      
      [FriendlyName("Send To", "Where to send this event. Choices are Parents (which is the default), Children, or All (broadcast).")]
      [SocketState(false, false)]
      uScriptCustomEvent.SendGroup sendGroup,

      [FriendlyName("Event Sender", "The GameObject responsible for sending the event. If not specified, the sender will be the owner of this uScript.")]
      [SocketState(false, false)]
      GameObject EventSender
      )
   {
      GameObject sender = m_Parent;
      if (EventSender != null) sender = EventSender;
      
      if (sendGroup == uScriptCustomEvent.SendGroup.All)
      {
         uScriptCustomEvent.BroadcastCustomEvent(EventName, EventValue, sender);
      }
      else if (sendGroup == uScriptCustomEvent.SendGroup.Children)
      {
         uScriptCustomEvent.SendCustomEventDown(EventName, EventValue, sender);
      }
      else
      {
         uScriptCustomEvent.SendCustomEventUp(EventName, EventValue, sender);
      }
   }
    public void SendCustomEvent(
        [FriendlyName("Event Name", "The string-based event name.")]
        string EventName,

        [FriendlyName("Event Value", "The value to pass in the event.")]
        GameObject EventValue,

        [FriendlyName("Send To", "Where to send this event. Choices are Parents (which is the default), Children, or All (broadcast).")]
        [SocketState(false, false)]
        uScriptCustomEvent.SendGroup sendGroup,

        [FriendlyName("Event Sender", "The GameObject responsible for sending the event. If not specified, the sender will be the owner of this uScript.")]
        [SocketState(false, false)]
        GameObject EventSender,

        [FriendlyName("Event Receivers", "The GameObjects that the event will be broadcasted on (allows for using a subset of all objects when using SendGroup.All).")]
        [SocketState(false, false)]
        GameObject[] EventReceivers = null
        )
    {
        GameObject sender = m_Parent;

        if (EventSender != null)
        {
            sender = EventSender;
        }

        if (sendGroup == uScriptCustomEvent.SendGroup.All)
        {
            if (EventReceivers != null && EventReceivers.Length > 0)
            {
                uScriptCustomEvent.BroadcastCustomEvent(EventName, EventValue, sender, EventReceivers);
            }
            else
            {
                uScriptCustomEvent.BroadcastCustomEvent(EventName, EventValue, sender);
            }
        }
        else if (sendGroup == uScriptCustomEvent.SendGroup.Children)
        {
            uScriptCustomEvent.SendCustomEventDown(EventName, EventValue, sender);
        }
        else
        {
            uScriptCustomEvent.SendCustomEventUp(EventName, EventValue, sender);
        }
    }