-
Notifications
You must be signed in to change notification settings - Fork 1
Main thread
VladyslavLapin edited this page May 7, 2024
·
1 revision
When using GenericExtrinsic from the Hexalem Integration, each transaction call is managed via the ExtrinsicManager. This setup allows for subscribing to transaction events with ExtrinsicUpdateEvent.
Important Note! that these events are external to Unity's main thread, so for UI updates, use UnityMainThreadDispatcher for thread-safe operations. This practice is crucial to prevent common issues when updating UI elements from callbacks from libraries outside of Unity.
Network.Client.ExtrinsicManager.ExtrinsicUpdated += OnExtrinsicUpdated;
private void OnExtrinsicUpdated(string subscriptionId, ExtrinsicInfo extrinsicInfo)
{
Debug.Log($"[{GetType().Name}] OnExtrinsicUpdated {subscriptionId} {extrinsicInfo.TransactionEvent}");
// dispatch to main thread as the call comes from outside
UnityMainThreadDispatcher.Instance().Enqueue(() =>
{
// do your updated here, to make sure they are shown.
});
}