Don't want to Subscribe and Unsubscribe from events or use Zenject dependency injection. Use Dynamic events instead. They are a tad bit slower in some cases but events are fire and forget and aren't called in Unity's Update() loop, so you really can't tell the difference until you have hundreds of game objects firing events.
Vivox events arent fired that often so unless you are updating hundreds of gameobejcts based on a players's name or login status you should be fine to use Dynamic Events.
Remember to use async void or async Task when using Dynamic Async events
Synchronous - Dynamic Events
publicclassDynamicAsyncEvents:MonoBehaviour{ [LoginEvent(LoginStatus.LoggingIn)]publicvoidLoginCallback(ILoginSession loginSession) {Debug.Log($"Invoking Async Event Dynamically from {nameof(LoginCallback)}"); } [LoginEvent(LoginStatus.LoggedIn)]publicvoidOnLoggedIn(ILoginSession loginSession) {awaitTask.Run(() => {for (int i =0; i <100; i++) {Debug.Log($"Method Event has been invoked dynamically"); } }); }}
Asynchronous - Dynamic Async Events
Reminder not to use Dynamic Async Events thatmodify the UI or GameObjects in Scene .
publicclassDynamicAsyncEvents:MonoBehaviour{ [LoginEventAsync(LoginStatus.LoggedIn)]publicasyncvoidDynamicEventAsyncVoid(ILoginSession loginSession) {var bytes =Encoding.Unicode.GetBytes(loginSession.LoginSessionId.DisplayName); using (FileStream fileStream = new FileStream($"{Directory.GetCurrentDirectory()}\\Assets\\playerName.txt", FileMode.Create, FileAccess.Write, FileShare.ReadWrite, bufferSize: 4096, useAsync: true))
{awaitfileStream.WriteAsync(bytes,0,bytes.Length); }Debug.Log("Done creating text file"); } [LoginEventAsync(LoginStatus.LoggedIn)]publicasyncTaskAsyncMethod(ILoginSession loginSession) {awaitTask.Run(() => {for (int i =0; i <100; i++) {Debug.Log($"Async Method Event has been invoked"); } }); }}