30/09/2018, 22:03

AddListener C# trong Unity

Mình đang tự học Unity nhưng có chỗ này không hiểu mong mọi người giúp đỡ.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class GamePlayManager : MonoBehaviour {

private Button resumeButton;
private GameObject pausePanel;
void Awake(){
	resumeButton = GameObject.Find ("ResumeGameButton").GetComponent<Button>();
	}
public void PauseGameButton(){
	Time.timeScale = 0f;
	pausePanel.SetActive (true);
	resumeButton.onClick.RemoveAllListeners ();
	resumeButton.onClick.AddListener (()=>ResumeButton());
}
public void ResumeButton(){
	Time.timeScale = 1f;
	pausePanel.SetActive(false);	
}
public void RestartButton(){
	Time.timeScale = 1f;
	Application.LoadLevel("GamePlay");	
}
public void FishDeadShowPanel(){
	Time.timeScale = 0f;
	pausePanel.SetActive (true);
	resumeButton.onClick.RemoveAllListeners ();
	resumeButton.onClick.AddListener (()=>RestartButton());
}

}

lỗi: Delegate UnityEngine.Events.UnityAction<UnityEngine.UI.Button>' does not take0’ arguments
ở 2 chỗ AddListener.
Cảm ơn mọi người.

Nguyễn Hoàng Trung viết 00:18 ngày 01/10/2018

https://community.unity.com/t5/Unity-UI/How-to-AddListener-featuring-an-argument/td-p/1862575

Bài liên quan
0