0

观看下面的代码片段,它工作正常(尽管方法执行尚未测试)并且我的方法已分配给补间 onFinsih。

没有 EventDelgate 和 EventDelegate 的第一行?那么将我的自定义方法分配给补间事件的区别和有效方法是什么。

using UnityEngine;
using System.Collections;

public class TweenEventMethodAssigner : MonoBehaviour {

    // Use this for initialization
    void Start () {
        gameObject.GetComponent<TweenPosition>().AddOnFinished(myOnFinish);
        gameObject.GetComponent<TweenPosition>().AddOnFinished(new EventDelegate(myOnFinish2));
    }

    // Update is called once per frame
    void Update () {

    }

    void myOnFinish() {
        Debug.Log("myOwnFinsih");
    }

    void myOnFinish2() {
        Debug.Log("myOwnFinsih : 2");
    }
}
4

1 回答 1

1

他们都一样。在内部使用第二个版本时,您使用第一个版本。这只是编写相同内容的一种更短的方法。

于 2016-02-19T07:18:08.747 回答