Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Yanger_xy · Apr 08, 2011 at 02:47 PM · guiwindowguilayoutsyncsnapshot

GUI.Window error. InvalidOperationException: Hashtable.Enumerator: snapshot out of sync.

I wanna to draw a menu. and here is the code, but i come across a problem when i hit Play,and i find the error is caused by this line of code below:GUI.Window(GlobalGUIWindowId._WND2_YXY..... ,and the error in the console window says:

InvalidOperationException: Hashtable.Enumerator: snapshot out of sync. System.Collections.Hashtable+Enumerator.FailFast () System.Collections.Hashtable+Enumerator.MoveNext () UnityEngine.GUI.EndWindows (UnityEngine.IDList idlist) (at C:/BuildAgent/work/f724c1acfee760b6/Runtime/ExportGenerated/Editor/GUI.cs:1225) UnityEngine.GUIUtility.EndGUI (Int32 doLayout, Int32 doWindows, UnityEngine.IDList idlist) (at C:/BuildAgent/work/f724c1acfee760b6/Runtime/ExportGenerated/Editor/GUIUtility.cs:359)

I have no idea how to debug it, may you help me. Thank you very much!

void OnGUI() { // _rectMainMenu = new Rect(_menuPos.x, _menuPos.y, Screen.width - _menuPos.x, _mainMenuHeight); _rectMainMenu = GUI.Window(GlobalGUIWindowId._WND1_YXY, _rectMainMenu, MenuMainWindow, "", _mainMenuBackStyle); } void MenuMainWindow(int windowId) { int nNumPopupMenus = _popupMenus.Count; float width = 0f; float x = 0f; for (int i = 0; i < nNumPopupMenus; i++) { PopupMenu popItem = (PopupMenu)_popupMenus[i]; popItem.SetStyles(_mainMenuBackStyle, _menuItemStyle, _menuDisableStyle); width = GUILayoutUtility.GetRect(new GUIContent(popItem.Text), _popupMenuStyle).width + _spaceBetweenMenuItems; print("text, width:" + popItem.Text + ", " + width.ToString()); Rect rectCur = new Rect(x, 0, width, _popupMenuHeight); popItem.DrawPopupMenu(rectCur, _popupMenuStyle); x += width; } }

public void DrawPopupMenu(Rect rect, GUIStyle popupMenuStyle) { GUIContent guiContent = new GUIContent(_text); GUI.Label(rect, guiContent, popupMenuStyle); // // _menuItemMaxWidth = 100;//not complete

 rectMax = new Rect(10, 10, _menuItemMaxWidth, 10);
 ***GUI.Window(GlobalGUIWindowId._WND2_YXY, rectMax,  DrawItsMenuItems, "", _mainMenuStyle);//***

}

private void DrawItsMenuItems(int windowId) { // //int nNumMenuItems = _menuItems.Count; //float y = 0; //for (int i = 0; i < nNumMenuItems; i++) //{ // MenuItem item = (MenuItem)_menuItems[i]; // if (item.Show) // { // // // // // _menuItemHeight = 18; // Rect rectMenuItem = new Rect(0, y, _menuItemMaxWidth, _menuItemHeight); // //item.DrawMenuItem(rectMenuItem, _menuItemStyle, _disableMenuItemStyle); // } // y += _menuItemHeight; //} }

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Displaying a tooltip with GUILayout.Window 1 Answer

Windows that do not take priority over other GUI elements 0 Answers

GUI Window Render Priority 1 Answer

How do i bring one GUI window in front of another? 1 Answer

Having a GUILayout Window position immediately at screen center 5 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges