x


"GUI Error: You are pushing more GUIClips than you are popping."

GUI Error:
You are pushing more GUIClips than you are popping.
Make sure they are balanced (type:Layout)

I think it's pointing to this code: (it is slighty modified - the real code is far more complex ;) )

var imageTexture:Texture=null;
var MyLib:MyLibClass=null;
var p:MyPictureObject=null;

function Start(){
    p=MyLib.GetARandomPicture();
}

function OnGUI(){
    if (imageTexture==null){
        var url=p.GetImage();
        if (url!="" && p.IsBusy()==false){
            p.SetBusy(true);
            Debug.Log("getting an image texture",this);
            if (p.GetImageTexture()!=null){
                Debug.Log("getting an image texture from cache",this);
                imageTexture=p.GetImageTexture();
            } else {
                Debug.Log("getting an image texture from web: "+url,this);
                var www=new WWW(url);
                yield www;
                p.SetimageTexture(www.texture);
                imageTexture=www.texture;
            }   
            p.SetBusy(false);
        }
    }
    GUILayout.Box(Rect(0,0,100,100), imageTexture);
    if (GUILayout.Button("a different image please")){
        p=MyLib.GetARandomPicture();
    }
}

I use p.SetBusy() and p.IsBusy() to avoid multiple requests for one image.

I use p.GetImageTexture() and p.SetImageTexture() for caching request responses.

So If I use caching and avoid asyncronous problems - why do I get something like a stackoverflow on the request buffer?

more ▼

asked Feb 26 '10 at 09:09 AM

eurosat7 gravatar image

eurosat7
177 7 8 15

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Problem solved:

Don't use yield in OnGUI() between GUILayout.BeginArea() and GUILayout.EndArea()

more ▼

answered Mar 01 '10 at 08:46 AM

eurosat7 gravatar image

eurosat7
177 7 8 15

StartCoroutine() is another way to avoid this error.

Mar 03 '10 at 03:46 PM eurosat7
(comments are locked)
10|3000 characters needed characters left

Regarding GUIClips: The case where I remember getting that error was when I had a GUILayout.BeginArea that didn't have a corresponding EndArea (or in general, a GUILayout.Begin[Something] that didn't have the corresponding End[Something] call). Have you checked that is not the case elsewhere in your code?

What do you mean by "something like a stackoverflow"? What does p.GetImage() do ?

Also, notice that if what you want to do is to have the image change every time you press the button, the code will likely not work anyway, as you only obtain a new image if the imageTexture is null, which it won't be after the first time you assign it.

more ▼

answered Feb 26 '10 at 02:32 PM

Ricardo gravatar image

Ricardo
5.2k 20 32 96

Thanks for your answer. It helped me to solve the problem. A yield after a BeginArea was blocking the EndArea so it was opening a lot of areas.

Mar 01 '10 at 08:48 AM eurosat7

My pleasure, glad it helped.

Mar 01 '10 at 11:14 AM Ricardo

Thankyou for this it helped alot. was getting an in finite loop because i forgot GUI.EndGroup(); lol

Apr 06 at 08:05 AM Packetstorm
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3695
x1951
x2

asked: Feb 26 '10 at 09:09 AM

Seen: 7354 times

Last Updated: Apr 06 at 08:08 AM