landonbradlee landonbradlee - 7 months ago 53
C# Question

Must have a body because it is not marked abstract, extern, or partial

Not entirely sure why I'm getting this error. Looked up and down the code for a few hours but I assuming it's a simple fix. Some of the code is copied over from a video and his works perfectly fine, so I don't know why it'd cause me any issues:

using UnityEngine;
using System.Collections;

public class GoldPerSec : MonoBehaviour {

public UnityEngine.UI.Text gpsDisplay();
public Click click;
public ItemManager[] items;

void Start() {

void Update() {
gpsDisplay.text = GetGoldPerSec() + " gold/sec";

public int GetGoldPerSec(){
int tick = 0;
foreach (ItemManager item in items) {
tick += item.count * item.tickValue;

return tick;

public void AutoGoldPerSec() { += GetGoldPerSec();

IEnumerator AutoTick() {
while (true) {
yield return new WaitForSeconds(1);


The problem is in

public UnityEngine.UI.Text gpsDisplay();

That is a method declaration, but there's no code inside the method.

It's unclear from the context what that should actually be. If it's a method, you can either implement it in this class, like

public UnityEngine.UI.Text gpsDisplay()
     return <something useful>;

Maybe it shall be a method and you want to implement it in a subclass, then mark the class as abstract:

public abstract class GoldPerSec : MonoBehaviour

Perhaps it should have been a field, then use

public UnityEngine.UI.Text gpsDisplay;

without the parentheses.