Firstly your code needs to call getPlaybackState every update to get the latest state.
If by looping you mean a loop-region on the logic track then the work flow would be:
- Add a parameter called trigger_finish_param to the event, leave the range at 0 to 1
- Change the loop-region so that it has a condition on the parameter from step 1, say only loop when the value is 0 to 0.5
- In unity call eventInst.setParameter(“trigger_finish_param”, 1.0f) followed by eventInst.release()
After you’ve done that the event will keep play until no instruments are active, then it will stop and clean itself up.