📜  CS0120:非静态字段、方法或属性“PlayerControls.currentState”需要对象引用 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:56.029000             🧑  作者: Mango

代码示例2
public class Upgrader1 : MonoBehaviour
{

PlayerController PlayerController; //It should be member variable

void Start()
{
    GameObject Player = GameObject.Find("Player");
    PlayerController = Player.GetComponent();
}

public void Upgrade1()
{
    PlayerController.speed++;
}
}