Unity AnimatorEvent

复制代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AnimatorEvent : StateMachineBehaviour
{
    static int statePropertyId = Animator.StringToHash("State");
    static Dictionary<int, string> hashToName = new Dictionary<int, string>();
    static AnimatorEvent()
    {
       foreach (string name in new string[] { "eat", "hit", "animation"})
          hashToName.Add(Animator.StringToHash(name), name);
    }

    
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
       animator.SetInteger(statePropertyId, -1);
       
    }
}
相关推荐
Rain的Java大神之路1 小时前
国家数据集团校招、社招都开了:总部雄安,这些技术岗值得认真看看
java·后端·面试
吴名氏.1 小时前
Java转AI Agent教程(第九周)错误矩阵
java·人工智能·矩阵·ai agent
文丑颜不良啊1 小时前
LeetCode1901~1920题目解析
java·leetcode
tealcwu2 小时前
【Unity基础】为什么游戏需要物理按键映射?从 Unity Input Manager 到跨引擎输入设计
java·游戏·unity
vipxieliang2 小时前
Spring Boot 性能优化实战:从启动加速到运行时调优
java·spring boot
AI全栈学习助手2 小时前
告别“转圈等待”:Spring Boot + SSE 让大模型像 ChatGPT 一样流式输出
java·人工智能·spring boot·后端·aigc
天天被压力2 小时前
【A股分钟级高频数据完全手册 #02】Python调用股票1分钟数据接口:Pro版最新分时取数与字段解析
java·人工智能·python
代码不停2 小时前
Spring Aop
java·数据库·spring
道尔柯南2 小时前
C++ STL 入门详解:从认识标准模板库到掌握学习方法
java·c++·学习方法