1084600–40629–$BugTest.unitypackage (2.29 KB)
I’ve attached a stripped down repro project that I’m trying to understand why it is an issue.
In this case I’m getting “ArgumentException: GUILayout: Mismatched LayoutGroup.mouseDown” and it is tied to having a HorizontalLayout. In my real project code not matter where I move it around I get random errors related to Mismatched LayoutGroup.
In my attached scenario, I have a game object that has a script attached that I want to load some data from the web. Here I’m just loading google.com for the sample. I then have a custom inspector that I want to use for debugging so I can force a load at any point I desire. So I keep a handle around so I know the point that I trigger it in the inspector and that I can change the inspector state once it has loaded.
Somehow all these problems are seeming related to that code that that is awaiting the game object to change state on an object the inspector holds a reference to.
TestInspector.cs
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomEditor(typeof(Test))]
public class TestInspector : Editor
{
RequestHandle _handle = null;
bool _loaded = false;
//Example inspector, the idea is that we can trigger loading www data for the object
//in question via the editor a debug method.
public override void OnInspectorGUI()
{
Test test = target as Test;
if(test != null)
{
if (!_loaded GUILayout.Button("Load"))
{
_handle = test.Load();
}
if(_handle != null _handle.status != RequestHandle.Status.Pending)
{
//Done...
_loaded = true;
}
if(_loaded)
{
//* Uncomment first two of this to swtich logic to working version
EditorGUILayout.BeginHorizontal();
{
//Everything falls apart with GUI mismatch errors... Why?!
//In this case it is ArgumentException: GUILayout: Mismatched LayoutGroup.mouseDown
//but using this same logic in acutal code causes all sorts of random results.
EditorGUILayout.LabelField("Loaded!");
}
EditorGUILayout.EndHorizontal();
/*/
EditorGUILayout.LabelField("Loaded!");
/**/
}
}
}
}
Update from Test.cs
void Update ()
{
Request [] list = _wwwRequestList.ToArray();
foreach(Request request in list)
{
if(request.www != null)
{
if(request.www.error != null)
{
if(Application.isEditor) Debug.LogWarning(request.www.error);
request.handle.status = RequestHandle.Status.Failed;
request.handle.error = request.www.error;
_wwwRequestList.Remove(request);
request.www.Dispose();
request.www = null;
}
else if(request.www.isDone)
{
request.handle.status = RequestHandle.Status.Succeeded;
_wwwRequestList.Remove(request);
request.www.Dispose();
request.www = null;
}
}
}
}
If you remove the Horizontal layout from the equation everything works as expected, however in my case I really want to make my GUI layed out with one.
Even more crazy, I’m finding that just setting _loaded will result in this behavior.
if(_handle != null _handle.status != RequestHandle.Status.Pending)
{
_handle = null;
_loaded = true;
}
if(_handle == null)
{
//* Uncomment first slash of this to swtich logic to working version
EditorGUILayout.BeginHorizontal();
{
//Everything falls apart with GUI mismatch errors... Why?!
//In this case it is ArgumentException: GUILayout: Mismatched LayoutGroup.mouseDown
//but using this same logic in acutal code causes all sorts of random results.
EditorGUILayout.LabelField("Loaded!");
}
EditorGUILayout.EndHorizontal();
/*/
EditorGUILayout.LabelField("Loaded!");
/**/
}
Now if I remove the _loaded = true; line it work.What is going on behind the scenes here that makes this logic so touchy?
if(_handle != null _handle.status != RequestHandle.Status.Pending)
{
_handle = null;
}
if(_handle == null)
{
EditorGUILayout.BeginHorizontal();
{
//Works now that _loading = true; is gone! But not the logic I want...
EditorGUILayout.LabelField("Loaded!");
}
EditorGUILayout.EndHorizontal();
}