SyncQueue
//Creates a new instance of the queue - `true` means it is owner auth.
[SerializeField] private SyncQueue<int> myQueue = new(true);
protected override void OnSpawned()
{
//Subscribing to changes made to the list
myQueue .onChanged += OnQueueChanged;
}
private void OnQueueChanged(SyncQueueChange<int> change)
{
//This is called for everyone when the queue changes.
//It will log out the value and operation
Debug.Log($"Queue updated: {change}");
}
private void ChangeMyQueue()
{
//This will enqueue into the queue
myQueue.Enqueue(69);
//This will dequeue the first element in the queue
myQueue.Dequeue();
//This will clear the queue
myQueue.Clear();
//This will peek at the first element
var myVal = myQueue.Peek();
}
SyncQueueChange
Last updated