Game/Library/PackageCache/com.unity.package-manager-ui@2.0.13/Editor/Sources/Services/Common/OperationSignal.cs
2021-01-16 18:29:12 +01:00

30 lines
674 B
C#

using System;
namespace UnityEditor.PackageManager.UI
{
[Serializable]
internal class OperationSignal<T> where T: IBaseOperation
{
public event Action<T> OnOperation = delegate { };
public T Operation { get; set; }
public void SetOperation(T operation)
{
Operation = operation;
OnOperation(operation);
}
public void WhenOperation(Action<T> callback)
{
if (Operation != null)
callback(Operation);
OnOperation += callback;
}
internal void ResetEvents()
{
OnOperation = delegate { };
}
}
}