x


How to make a dynamic GUI ?

Hello there !

I'm having some troubles making an ingame interface with Unity GUI. Basically, I want to create a small interface to manage a database. Database isn't the problem actually, the problem is Unity GUI itself.

If I have understood the Unity GUI system well, OnGUI() is called twice in a frame : the first time for layouting, the second time for paiting. Sometimes in my script, I refresh the DB view in my GUI which means that the GUI will change. It causes that error : "GUILayout: Mismatched LayoutGroup.Repaint", which seems to be obviously related to the above-mentioned problem.

My question is simple : How can I avoid that problem ? Are there Unity GUI properties that would enable me to know which state the GUI system is currently in ?

Thanks in advance for your answer :)

more ▼

asked Jul 08 '12 at 12:10 AM

DocteurCox gravatar image

DocteurCox
578 15 25 31

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

2 answers: sort voted first

You can check Event.current.type to see what the EventType is.

more ▼

answered Jul 08 '12 at 12:23 AM

Eric5h5 gravatar image

Eric5h5
102k 50 165 622

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

change state only at end of frame using coroutines or in layout event. check event in OnGUI in Event.current.type

more ▼

answered Jun 07 '13 at 08:36 PM

Ashkan_gc gravatar image

Ashkan_gc
9.9k 36 59 123

(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:

x22

asked: Jul 08 '12 at 12:10 AM

Seen: 978 times

Last Updated: Jun 07 '13 at 08:36 PM