如何给一个动画事件调用的函数传参数
1个回答
展开全部
using UnityEngine;
using System.Collections;
public class Try : MonoBehaviour {
public class Action : ScriptableObject
{
public Transform Att;
public Transform Def;
}
// Use this for initialization
void Start () {
Action act = new Action();
act.Att = this.transform;
act.Def = this.transform;
AnimationEvent evt = new AnimationEvent();
evt.time = 0;
evt.functionName = "Test";
evt.objectReferenceParameter = act as Object;
animation.GetClip("ani").AddEvent(evt);
Debug.Log(act.Att.gameObject.name);
}
public void Test(Action obj) {
Action act = obj as Action;
Debug.Log(act.Att.gameObject.name);
}
}
using System.Collections;
public class Try : MonoBehaviour {
public class Action : ScriptableObject
{
public Transform Att;
public Transform Def;
}
// Use this for initialization
void Start () {
Action act = new Action();
act.Att = this.transform;
act.Def = this.transform;
AnimationEvent evt = new AnimationEvent();
evt.time = 0;
evt.functionName = "Test";
evt.objectReferenceParameter = act as Object;
animation.GetClip("ani").AddEvent(evt);
Debug.Log(act.Att.gameObject.name);
}
public void Test(Action obj) {
Action act = obj as Action;
Debug.Log(act.Att.gameObject.name);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询