Newbie here with a GUILayout.Window() issue.

Hey all. I’m pretty new to Unity, and have been watching a couple of awesome video tutorial series for awhile now (BurgZerg and GTGD, and I’ve decided to get my hands dirty and start coding some of my own stuff. I’ve run into an issue making a window for my Single Player startup window using the GUILayout.Window() method. I’m sure it’s something ridiculous that I’m missing, but I’ve tried all I can think of to get it to work. The parameters are in the same format as other windows that work just fine, and compared to the documentation it looks ok, but I’m getting this error when I switch back to Unity:

Assets/Scripts/SinglePlayer.cs(22,42): error CS0123: A method or delegate SinglePlayer.SPWindow()' parameters do not match delegate UnityEngine.GUI.WindowFunction(int)’ parameters

Here is my code: I’d really appreciate any help!

using UnityEngine;
using System.Collections;

public class SinglePlayer : MonoBehaviour {
	
	private bool inSPGame = false;
	
	private string SPtitleMessage = "";
	private Rect SPWindowRect;	
	private int SPWindowWidth = 400;	
	private int SPWindowHeight = 280;	
	private int SPbuttonHeight = 60;	
	private int SPleftIndent;	
	private int SPtopIndent;
	
	void OnGUI(){
		SPleftIndent = (Screen.width / 2) - (SPWindowWidth / 2);
		SPtopIndent = (Screen.height / 2) - (SPWindowHeight / 2);
		
		SPWindowRect = new Rect(SPleftIndent, SPtopIndent, SPWindowWidth, SPWindowHeight);
		
		SPWindowRect = GUILayout.Window(3, SPWindowRect, SPWindow, SPtitleMessage);		
	}
	
	void SPWindow(){
	if(inSPGame == false){
		GUILayout.Space(15);
			
		if(GUILayout.Button("Start", GUILayout.Height(SPbuttonHeight))){
			inSPGame = true;
			}
		GUILayout.Space(5);
		
		if(GUILayout.Button("Go Back", GUILayout.Height(SPbuttonHeight))){
			inSPGame = false;
			}
		}

The function for the window needs an int parameter; see the code examples in the docs.

–Eric

Thanks Eric. I knew it was something silly that I missed.