要调用另一个物体里的组件里的方法的书写

要调用另一个物体里的组件里的方法

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class peng : MonoBehaviour
{
    
    
   void OnTriggerEnter2D(Collider2D collision)
    {
    
    
        if(collision.tag=="tou")
        {
    
    
            GameObject.Find("Gamemangen").GetComponent<Gamemange>().GameOver();
        }
    }
   
}

猜你喜欢

转载自blog.csdn.net/qq_46289420/article/details/109299309