// Copyright (c) Alexander Bogarsukov.
// Licensed under the MIT license. See the LICENSE.md file in the project root for more information.
using System;
using System.Collections;
using System.Threading;
using System.Threading.Tasks;
using UnityEngine;
namespace UnityFx.Tasks
{
///
/// Extensions methods for .
///
public static class AnimatorExtensions
{
#region interface
///
/// Configures await while the specified state is playing.
///
/// Source animation controller.
/// Name of the state to play.
/// The layer index. If layer is -1, it plays the first state with the given state name.
/// An awaitable opject.
public static CompilerServices.AnimatorWhileAwaitable ConfigureAwait(this Animator animator, string stateName, int layer = 0)
{
return new CompilerServices.AnimatorWhileAwaitable(animator, Animator.StringToHash(stateName), layer);
}
///
/// Configures await while the specified state is playing.
///
/// Source animation controller.
/// Hash of the state name.
/// The layer index. If layer is -1, it plays the first state with the given state name.
/// An awaitable opject.
public static CompilerServices.AnimatorWhileAwaitable ConfigureAwait(this Animator animator, int stateNameHash, int layer = 0)
{
return new CompilerServices.AnimatorWhileAwaitable(animator, stateNameHash, layer);
}
///
/// Configures await until the specified state is activated.
///
/// Source animation controller.
/// Name of the state to play.
/// The layer index. If layer is -1, it plays the first state with the given state name.
/// An awaitable opject.
public static CompilerServices.AnimatorWhileAwaitable ConfigureAwaitUntil(this Animator animator, string stateName, int layer = 0)
{
return new CompilerServices.AnimatorWhileAwaitable(animator, Animator.StringToHash(stateName), layer);
}
///
/// Configures await until the specified state is activated.
///
/// Source animation controller.
/// Hash of the state name.
/// The layer index. If layer is -1, it plays the first state with the given state name.
/// An awaitable opject.
public static CompilerServices.AnimatorWhileAwaitable ConfigureAwaitUntil(this Animator animator, int stateNameHash, int layer = 0)
{
return new CompilerServices.AnimatorWhileAwaitable(animator, stateNameHash, layer);
}
#endregion
#region implementation
#endregion
}
}