NGUI: The member cannot be used as method or delegate

Hey! Iam trying to get into NGUI and wanted to try to adapt this simple OnGUI Script:

using UnityEngine;
using System.Collections;

public class CashViewOld : MonoBehaviour 
{
		
	private SpawnController	m_spawnController			= null;
	
	void Awake()
	{
		m_spawnController = GameObject.FindWithTag("SpawnController").GetComponent<SpawnController>();
		
	}


	void OnGUI()
	{
		Vector2 buttonSize = new Vector2(120, 40);
		Rect startPosTop = new Rect(90, 30, buttonSize.x, buttonSize.y);

		GUI.Label(new Rect(startPosTop.x + 80.0f, startPosTop.y - 25.0f, 100.0f, 30.0f), "CASH: " + m_spawnController.m_playerCash);
	}
}

to this NGUI script:

using UnityEngine;
using System.Collections;

public class CashView : MonoBehaviour {
	
	public UILabel resourceLabel;
	//private int displayedResources;

	private SpawnController	m_spawnController			= null;
	
	void Awake()
	{
		m_spawnController = GameObject.FindWithTag("SpawnController").GetComponent<SpawnController>();
	}
	
	public void UpdateResource(bool instant = false) {
		resourceLabel.text = "CASH: " + m_spawnController.m_playerCashh();
		}

}

but all I get is this error:
CashView.cs(17,67): error CS1955: The member `SpawnController.m_playerCash’ cannot be used as method or delegate

can somebody tell me what that means?

In the fist script m_playerCash is a variable of SpawnController, in the second script you are using it like a function and you have also written it incorrectly.

okay. like this its working:

using UnityEngine;
using System.Collections;

public class CashView : MonoBehaviour {
	
	public UILabel resourceLabel;
	//private int displayedResources;

	private SpawnController	m_spawnController			= null;
	
	void Awake()
	{
		m_spawnController = GameObject.FindWithTag("SpawnController").GetComponent<SpawnController>();
	}
	
	public void UpdateResource(bool instant = false) {
		resourceLabel.text = ("CASH: " + m_spawnController.m_playerCash);
		}

}

but sadly it doesn’t display the value in the label. but i think thats an other problem. at least is do not throw any errors. thanks :slight_smile: