Unity - A计划(一年有效期) 扫二维码继续学习 二维码时效为半小时

(61评价)
价格: 2165.00元
【Unity中的C#编程 - 零基础(Unity 2017)】public void没有办法引用
Xinxin22559发起了问答2021-10-29
1
回复
348
浏览

异常信息

NullReferenceException: Object reference not set to an instance of an object
Learn05_acess_component.Start () (at Assets/spcripts/Learn05_acess_component.cs:27)

出现问题的代码


public class Learn02_Player2 : MonoBehaviour {

	public int hp = 200;

	public void Start () {
		print(hp);
	}
	public Learn02_Player2 learn02;

	void Start () {
		learn02.Start();
	}

 

所有回复
  • 老师_Trigger 2021-10-30

    同学你好,Start方法不需要调用,Unity自己可以调用,如果想要调用其他方法,可以把上边那个方法更换一个名字,Start方法比较特殊

    还有-5条回复,点击查看
    你还没有登录,请先登录注册
发表回复
你还没有登录,请先 登录或 注册!