Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question How to trigger a custom event in C# for a coroutine

Discussion in 'Visual Scripting' started by emrys90, Feb 11, 2021.

  1. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    752
    How do you trigger an event in C# for a coroutine? This works fine when it's not a coroutine, but if I check the coroutine box it gives an error

    var reference = GraphReference.New(macro, false);
    reference.TriggerEventHandler(hook => hook.name == "Custom", new CustomEventArgs("ActivateAbility"), parent => true, true);
     
  2. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    752
    It gives the following error by the way:
    NullReferenceException: Object reference not set to an instance of an object
    Ludiq.GraphPointer.GetElementData[T] (Ludiq.IGraphElementWithData element) (at Ludiq.Graphs.Runtime/GraphPointer.cs:346)
    Bolt.EventUnit`1[TArgs].Run (Bolt.Flow flow) (at Bolt.Flow.Runtime/Framework/Events/EventUnit.cs:175)
    Bolt.EventUnit`1[TArgs].Trigger (Ludiq.GraphReference reference, TArgs args) (at Bolt.Flow.Runtime/Framework/Events/EventUnit.cs:150)
    Bolt.XEventGraph.TriggerEventHandler[TArgs] (Ludiq.GraphReference reference, System.Func`2[T,TResult] predicate, TArgs args, System.Func`2[T,TResult] recurse, System.Boolean force) (at Bolt.Core.Runtime/Events/IEventGraph.cs:18)
    BattleManager.ExecuteOutputMacro (Ludiq.GraphReference reference) (at Assets/BattleManager.cs:43)
    BattleManager.Start () (at Assets/BattleManager.cs:20)
     
  3. LaFoster

    LaFoster

    Joined:
    May 19, 2019
    Posts:
    1
    Did you figure this out? I just ran into the same problem and could really use a helping hand here :/
     
  4. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    752
    Nope, I did not