GUI error : Getting control 0'd position in a group with only 0 controls when doing..

Hi,

I read some threads on this forum about this error but I still can not solve it.

Here is my code that create this error when I click on the button, if somebody could help me :

using UnityEngine;
using System.Collections;

public class Test : MonoBehaviour {

    private bool isFlee = false;
	private Rect fleeWindow;
	public GUISkin fantasyGUI;
	
	void Awake ()
	{
		fleeWindow = new Rect((Screen.width / 2) - (400 / 2), (Screen.height / 2) - (400 / 2), 400, 400);
	}
	

    void OnGUI (){
        GUI.skin = fantasyGUI;
        if (GUI.RepeatButton(new Rect(100, 200, 200, 50), "Click me")  isFlee == false)
        {
            isFlee = true;
        }

        if (isFlee == true)
        {
            fleeWindow = GUI.Window(0, fleeWindow, DrawFleeWindow, "");
        }
    }

    void DrawFleeWindow(int windowID)
    {
        GUILayout.Box("Do you really want to flee?");

        if (GUILayout.RepeatButton("YES"))
        {
        }

        if (GUILayout.RepeatButton("NO"))
        {
            isFlee = false;
        }
    }
}

Thanks in advance and sorry to throw some code like that,

Cizia

Bump

Seems GUILayout functions have problems when within the GUI.Window.

I tried using the GUI methods and it works fine.

using UnityEngine;
using System.Collections;
 
public class Test2 : MonoBehaviour { 
    private bool isFlee = false;
    private Rect fleeWindow;
    public GUISkin fantasyGUI;

    void Awake ()
    {
        fleeWindow = new Rect((Screen.width / 2) - (250 / 2), (Screen.height / 2) - (250 / 2), 250, 100);
    }    

    void OnGUI (){
        GUI.skin = fantasyGUI;
        if (GUI.RepeatButton(new Rect(100, 200, 200, 50), "Click me")  isFlee == false)
        {
            isFlee = true;
        } 
        if (isFlee == true)
        {
            fleeWindow = GUI.Window(0, fleeWindow, DrawFleeWindow, "");
        }
    }
 
    void DrawFleeWindow(int windowID)
    {
        GUI.Box(new Rect(10, 10, fleeWindow.width - 20, 30), "Do you really want to flee?"); 
        if (GUI.RepeatButton(new Rect(10, 50, 110, 40), "YES"))
        {
        } 
        if (GUI.RepeatButton(new Rect(130, 50, 110, 40), "NO"))
        {
            isFlee = false;
        }
    }
}

Hi dkozar,

Thanks a lot for this answer, is opens a lot of door to me.

Best regards,

Cizia