Hello again, it’s always me, I almost finish the thing, but there’s a last problem:
InvalidOperationException: Operation is not valid due to the current state of the object
System.Collections.Generic.Stack`1[System.Boolean].Pop ()
UnityEditor.EditorGUI.EndDisabledGroup () (at /Users/builduser/buildslave/unity/build/Editor/Mono/EditorGUI.cs:211)
UnityEditor.EditorGUI+DisabledGroupScope.CloseScope () (at /Users/builduser/buildslave/unity/build/Editor/Mono/EditorGUI.cs:197)
UnityEngine.GUI+Scope.Dispose ()
UnityEditor.Editor.OptimizedInspectorGUIImplementation (Rect contentRect) (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/editor/EditorBindings.gen.cs:234)
UnityEditor.GenericInspector.OnOptimizedInspectorGUI (Rect contentRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/GenericInspector.cs:33)
UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1211)
UnityEditor.InspectorWindow.DrawEditors (UnityEditor.Editor[ ] editors) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1028)
UnityEditor.InspectorWindow.OnGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:352)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[ ] parameters,
what I am suppose to do?
You’re probably invoking EditorGUI.EndDisabledGroup before calling start disabled group or popping smoe other kinds of elements.
Try disabling parts of the code that evolves rendering your custom editor and see when it stops throwing the exception . Then when you found the section which causes the problem you can try and figure you if you do too many “GUIXX.EndXXX” calls compared to “GUIXX.BeginXX” calls, also if you have a if( state == ?? ) Begin that might caurse it.
Also the OnGUI / OnInspectorGUI gets called more than once each frame by diffirent events, so you might have a problem occuring when just one of the events is firering.
Cheers!
using UnityEngine;
using System.Collections;
public class GameCenter : MonoBehaviour {
public static int PlayerScore1=0;
public static int PlayerScore2=0;
public GUISkin layout;
public GameObject theBall;
public GameObject respawn;
//Usethisfor initialization
void Start () {
theBall = GameObject.FindGameObjectWithTag("Ball");
respawn = GameObject.FindWithTag("Respawn");
}
public static void Score (string wallID) {
if (wallID == "rightWall") {
PlayerScore1++;
} else {
PlayerScore2++;
}
}
void OnGui(){
GUI.Label (new Rect (Screen.width / 2 - 150 - 12, 20, 100, 100), "Player1" + PlayerScore1);
GUI.Label (new Rect (Screen.width / 2 - 150 - 12, 20, 100, 100), "Player2" + PlayerScore2);
if (GUI.Button (new Rect (Screen.width / 2 - 60, 35, 120, 53), "RESET")) {
PlayerScore1 = 0;
PlayerScore2 = 0;
theBall.gameObject.SendMessage ("resetBall", .5f, SendMessageOptions.RequireReceiver);
}
if (PlayerScore1 == 10) {
GUI.Label (new Rect (Screen.width / 2 - 150, 200, 2000, 1000), "Player1WINS");
theBall.gameObject.SendMessage ("hasWon", null, SendMessageOptions.RequireReceiver);
}else if (PlayerScore2 == 10){
GUI.Label (new Rect (Screen.width / 2 - 150, 200, 2000, 1000), "Player2WINS");
theBall.gameObject.SendMessage ("hasWon", null, SendMessageOptions.RequireReceiver);
}
}
}
this is my code, i’m not sure if I do somethign right