SendMessageUpwards & SendMessage

using UnityEngine;
using System.Collections;

//  王民光是他的祖父
public class WangShaoWen : MonoBehaviour
{
    void Start()
    {

    }

    void Update()
    {

    }

    public void Report(string content)
    {
        Debug.Log(content + " at WangShaoWen !");
    }
}
using UnityEngine;
using System.Collections;

//  王民光是他的父亲
public class WangMinGuang : MonoBehaviour
{
    void Start()
    {

    }

    void Update()
    {

    }

    public void Report(string content)
    {
        Debug.Log(content + " at WangMinGuang !");
    }
}

using UnityEngine;
using System.Collections;

//  王亮亮是我最好的朋友
public class WangLiangLiang : MonoBehaviour
{
    void Start()
    {
        //  将调用所有上级代码中的Report方法, 
        //  以及同该代码依附在同一GameObject上的Repost方法
        SendMessageUpwards("Report", "AAAAAAAAAAAAAAAAA");

        //  将调用同该代码依附在同一GameObject上的Repost方法
        SendMessage("Report", "AAAAAAAAAAAAAAAAA");
    }

    void Update()
    {

    }

    public void Report(string content)
    {
        Debug.Log(content + " at WangLiangLiang !");
    }
}


你可能感兴趣的:(String,report,Class)