-
Notifications
You must be signed in to change notification settings - Fork 0
Events and Main thread
Cedric Decoster edited this page Jan 2, 2024
·
2 revisions
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.
});
}