Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

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:
    763
    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:
    763
    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:
    763
    Nope, I did not