How to pass event info to events?
I adapted a simple raycast event trigger based on this beautiful answer: 
 
 public class RaycastTrigger: MonoBehaviour
 {
     #region IRaycastTriggerHandler implementation
 
     public void ReceiveRaycast(RaycastHit hit)
     {
         RaycastEventTrigger();
     }
 
     #endregion
  
     //my event
     [Serializable]
     public class  RaycastTriggerEvent: UnityEvent { }
     
 
     [SerializeField]
     private RaycastTriggerEvent raycastTriggerEvent = new RaycastTriggerEvent();
     public RaycastTriggerEvent onRaycastEvent { get { return onRaycastEvent; } set { onRaycastEvent = value; } }
 
     public void RaycastEventTrigger()
     {
         onRaycastEvent.Invoke();
     }
 }
 This allows me to raycast to objects and press a button in order to invoke methods added in the editor, as you would by clicking a button:
 
 
 
 I want to add a script to the event trigger that uses the RaycastHit received by the trigger. Specifically, I want to pass the triangle hit to a script that is invoked by the event. 
 
 My question is, how do I pass parameters from the event to the scripts that it invokes?
Answer by Hellium · Mar 29, 2019 at 07:27 PM
 //my event
  [Serializable]
  public class  RaycastTriggerEvent : UnityEvent<RaycastHit> { }
  public void ReceiveRaycast(RaycastHit hit)
  {
      RaycastEventTrigger(hit);
  }
 
  public void RaycastEventTrigger(RaycastHit hit)
  {
      onRaycastEvent.Invoke( hit );
  }
Your answer
 
 
             Follow this Question
Related Questions
Making UI block rays with touch inputs 0 Answers
Event not being invoked 2 Answers
Help with Unity Events 0 Answers
Twitch Chat Emotes & Alerts to trigger events C# 0 Answers
OnPointerClick only triggers when clicked on the top part of UI Image 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                