c# - Unity c#我尝试执行方法时出错
问题描述
我有这个代码第一个文件
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Controller : MonoBehaviour
{
public Machines machines;
void Start()
{
machines = new Machines();
machines.ClickSpeedUpgrade();//here I get the error
}
}
第二个文件
using System.Collections;
using System.Collections.Generic;
using BreakInfinity;
public class Machines
{
public void ClickSpeedUpgrade()
{
//some code
}
}
NullReferenceException:对象引用未设置为对象的实例
为什么我会收到此错误,我该如何解决?
解决方案
推荐阅读
- python-3.x - 将 swagger_client 导入 python 项目以运行 strava API
- python - 如何使用 PySpark 计算 ADLS 中的目录大小?
- c++ - 视频处理器 MFT 导致错误“请求在当前状态下无效”
- python - 用于文件字典的python结构
- netbeans - 资源文件夹中的 Netbeans Designer 和 .form 文件
- html - 如果命令在 if 语句中,则 html 视频不会暂停
- ios - Xcode 音频播放器突然停止工作?
- android - 旋转设备时 Recyclerview 数据消失
- r - R中带有permtest函数的这段代码有什么问题?
- mongodb - 在 MongoDB 中计算数组中的不同值