public UpdateTaskGeneric(Action <T> updateAction, Func <T, bool> endCondition, T sender, Action endAction = null) { EndAction = endAction; dataQueue = new Queue <ActionGenericData>(); currentData = new ActionGenericData(updateAction, endCondition, sender); this.sender = sender; if (sender is UnityEngine.Object obj) { CalledInstanceId = obj.GetInstanceID(); } }
public void Tick() { currentData.Invoke(); if (!currentData.CheckEnd()) { if (dataQueue.Count == 0) { EndAction?.Invoke(); Dispose(); return; } currentData = dataQueue.Dequeue(); } }
public UpdateTaskGeneric <T> Join(ActionGenericData actionData) { dataQueue.Enqueue(actionData); return(this); }