50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public static class UnityExpandFunction
|
|
{
|
|
/// <summary>
|
|
/// 检测动画标签
|
|
/// </summary>
|
|
/// <param name="animator"></param>
|
|
/// <param name="tagName"></param>
|
|
/// <param name="animationIndex"></param>
|
|
/// <returns></returns>
|
|
public static bool CheckAnimationTag(this Animator animator, string tagName, int animationIndex = 0)
|
|
{
|
|
return animator.GetCurrentAnimatorStateInfo(animationIndex).IsTag(tagName);
|
|
}
|
|
/// <summary>
|
|
/// 检测动画片段名称
|
|
/// </summary>
|
|
/// <param name="animator"></param>
|
|
/// <param name="animationName"></param>
|
|
/// <param name="animationIndex"></param>
|
|
/// <returns></returns>
|
|
public static bool CheckAnimationName(this Animator animator, string animationName, int animationIndex = 0)
|
|
{
|
|
return animator.GetCurrentAnimatorStateInfo(animationIndex).IsName(animationName);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 贝塞尔曲线
|
|
/// </summary>
|
|
/// <param name="t"></param>
|
|
/// <param name="a"></param>
|
|
/// <param name="b"></param>
|
|
/// <param name="c"></param>
|
|
/// <returns></returns>
|
|
public static Vector2 Bezier(float t, Vector2 a, Vector2 b, Vector2 c)
|
|
{
|
|
var ab = Vector2.Lerp(a, b, t);
|
|
var bc = Vector2.Lerp(b, c, t);
|
|
return Vector2.Lerp(ab, bc, t);
|
|
}
|
|
public static CameraVR GetCamera()
|
|
{
|
|
return GameObject.FindWithTag("Camera").GetComponentInChildren<CameraVR>();
|
|
}
|
|
}
|