ModAPI threading

Discussion in 'Empyrion API' started by imlarry425, Mar 15, 2026 at 11:14 PM.

  1. imlarry425

    imlarry425 Captain

    Joined:
    Jan 10, 2019
    Messages:
    469
    Likes Received:
    340
    Big dho moment for me ... async message handlers run on background threads. I had several API I could never get to work- ShowEntity, Teleport, ShowGameMessage, MoveEntity

    Any ModAPI call that touches a live Unity object — LocalPlayer, entity positions, GUI methods, playfield mutations- all return null or throw when run from a background thread. Wrapping these calls in the mod's main thread dispatcher resolves it. Probably obvious to Unity developers; worth a note for those of us coming from other backgrounds.

    If the devs could add something to this effect to the ModAPI docs it could really help anybody who hasn't worked with Unity before.
     
    #1

Share This Page