這裏是我的功能:我如何在C#中統一解決這個問題
public void PowerupCollected(int AddScore)
{
score += AddScore;
scoreGUI.text = "lol"+score;
}
這是我如何調用該函數:
if(other.gameObject.name == "Powerup(Clone)")
{
control.PowerupCollected();
}
這裏是錯誤消息
錯誤CS1501:沒有過載方法`PowerupCollected'需要0個參數
有什麼問題?是否因爲我在調用函數時在括號中不包括AddScore
?
你有沒有讀過你的錯誤信息?如果是這樣,請再閱讀一次。 –
*是否因爲我在調用函數時未在括號中包含AddScore *答案爲是。 – tchelidze
你也可以聲明這樣的函數:** public void PowerupCollected(int AddScore = 0){} **,使參數變爲可選 –