InventoryDatabase.SyncRequest
#
Declarationpublic virtual void SyncRequest(Object request)
#
ParametersName | Description |
---|---|
request | Request to sync |
#
DescriptionSync a request to the main GUI thread
#
Usageusing NullSave.GDTK.Inventory;using System;using System.Threading;using UnityEngine;
public class Example : MonoBehaviour{
public void ExampleMethod() { // The Sync Request allows you to execute items outside the GUI thread // And then sync back to the main thread for events, UI, etc. new Thread(() => UnsafeThread()).Start(); }
private void UnsafeThread() { for (int i = 0; i < 100; i++) { Action action = () => { SafeAction(i); }; InventoryDatabase.instance.SyncRequest(action); } }
private void SafeAction(int i) { Debug.Log("Sync instance: " + i); }
}