C#Unity:由于保护级别

时间:2018-03-22 01:33:15

标签: c# unity3d

帮助!我得到一个错误!

  

Assets / PlayerCollision.cs(12,36):错误CS0122:   `GameManager.EndGame()'由于其保护级别而无法访问

这是我的碰撞检测代码:

using UnityEngine;

public class PlayerCollision : MonoBehaviour {

    public PlayerMovement movement;

    void OnCollisionEnter(Collision collisionInfo) 
    {
        if (collisionInfo.collider.tag == "Obsticle")
        {
            movement.enabled = false;
            FindObjectOfType<GameManager>().EndGame();
        }
    }

}

GameManager类:

using UnityEngine; 

public class GameManager : MonoBehaviour { 
   public void EndGame() { 
      Debug.Log("Game Over"); 
   } 
} 

0 个答案:

没有答案