Unity无效操作异常:System.Collects.Stack.Peek() - 由于当前状态操作无效?

时间:2016-10-16 04:17:41

标签: c# .net mono

所以,我去统一运行构建,我得到了这个!

  

InvalidOperationException:由于当前操作,操作无效   对象的状态System.Collections.Stack.Peek()(at   /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections/Stack.cs:321)   UnityEngine.GUILayoutUtility.EndLayoutGroup()(at   C:/buildslave/unity/build/Runtime/IMGUI/Managed/GUILayoutUtility.cs:280)   UnityEngine.GUILayout.EndScrollView(Boolean handleScrollWheel)(at   C:/buildslave/unity/build/Runtime/IMGUI/Managed/GUILayout.cs:427)   UnityEditor.EditorGUILayout.EndScrollView()(at   C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:7090)   UnityEditor.ListViewShared + ListViewElementsEnumerator.MoveNext()(at   C:/buildslave/unity/build/Editor/Mono/GUI/ListViewShared.cs:654)   UnityEditor.ConsoleWindow.OnGUI()(at   C:/buildslave/unity/build/Editor/Mono/ConsoleWindow.cs:409)   System.Reflection.MonoMethod.Invoke(System.Object obj,BindingFlags   invokeAttr,System.Reflection.Binder binder,System.Object []

我之前从未见过这样的例外情况,所以我想我会询问它然后进行调查。

1 个答案:

答案 0 :(得分:0)

请勿在空Peek上调用PopStack<T>

Stack<GameObject> stack = new Stack<GameObject> ();
if (stack.Count > 0) {
    var top = stack.Peek ();
}