InventoryDatabase.SyncRequest
Declaration#
public virtual void SyncRequest(Object request)Parameters#
| Name | Description |
|---|---|
| request | Request to sync |
Description#
Sync a request to the main GUI thread
Usage#
using 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); }
}