Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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:
    755
    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:
    755
    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:
    755
    Nope, I did not