Custom editor EditorGUILayout.BeginHorizontal not executing

We have ruled out that it’s not Plastic.
*** EDIT ***

Hey, I’m suddenly having problems when using the Editor function EditorGUILayout.BeginHorizontal() and I’m tracing it to PlasticSCM somehow.

I’m using Unity 2019.4.35f1 with the Version Control package updated to 1.14.15

If I run the code below it works fine.
But if I un-comment lines 15 and 25 then something breaks.

            for (int i = 0; i < m_TrackChannels.arraySize; i++)
            {
                var _audioClip = m_TrackChannels.GetArrayElementAtIndex(i).FindPropertyRelative("m_AudioClip");
                if (_audioClip.objectReferenceValue == null)
                {
                    m_TrackChannels.DeleteArrayElementAtIndex(i);
                    break;
                }

                switch (m_Mode)
                {
                    case Mode.EditChannels:
                        {
                            //EditorGUILayout.BeginHorizontal();
                            {
                                if (GUILayout.Button("X", GUILayout.Width(20f)))
                                {
                                    m_TrackChannels.DeleteArrayElementAtIndex(i--);
                                    serializedObject.ApplyModifiedProperties();
                                    return;
                                }
                                EditorGUILayout.PropertyField(_audioClip, GUIContent.none, true,  GUILayout.ExpandWidth(true));
                            }
                            //EditorGUILayout.EndHorizontal();

                            GUILayout.Space(10f);
                        }
                        break;

                    case Mode.ModifyMusic:
                        {
                            EditorGUILayout.BeginHorizontal();
                            {
                                var _enabled = m_TrackChannels.GetArrayElementAtIndex(i).FindPropertyRelative("m_Enabled");
                                EditorGUILayout.PropertyField(_enabled, GUIContent.none, true, GUILayout.Width(20f));
                                EditorGUILayout.PropertyField(_audioClip, GUIContent.none, true, GUILayout.ExpandWidth(true));
                            }
                            EditorGUILayout.EndHorizontal();

                            EditorGUILayout.BeginHorizontal();
                            {
                                EditorGUILayout.LabelField("Volume", GUILayout.Width(50f));
                                var _volume = m_TrackChannels.GetArrayElementAtIndex(i).FindPropertyRelative("m_ChannelVolume");
                                _volume.floatValue = EditorGUILayout.Slider(_volume.floatValue, 0f, 1f);
                            }
                            EditorGUILayout.EndHorizontal();

                            GUILayout.Space(20f);
                        }
                        break;

                    default:
                        Debug.LogError("Missing case: " + m_Mode);
                        break;
                }
            }

There are no errors or warnings.
If I set a break point on line 15, then press F10, I get here in my code:

This is a PlasticSCM editor scipt.
It executes until line 61 and returns.
Execution then continues into another PlasticSCM editor script where it does nothing and returns.

That’s as far as I can trace the code before control is returned to Unity.
The execution never returns to my editor script and as I said there are no errors or warnings.

I’m so confused.

Why not post this on the dedicated Version Control forum that has a dedicated Plastic SCM sub-forum here?

I can move your post for you if you wish.

In not sure if plastic is causing this, or if plastic is simply next in line on the stack trace after the execution fails in my editor script.

I was unable to reproduce this with my simplified attempt.

To confirm if Plastic SCM is the culprit, can you temporarily remove the Version Control package from your project?

I removed it and the problem is unchanged, so it’s definitely not Plastic.

When I again try to debug, the execution simply stops after line 15 and then the next
OnInspectorGUI cycle begins.

Hold on, from what you’re saying here it seems you’re talking about the VS Code debugging and simply shifting the display to another thread or same thread? If you send some debug output, are you sure it’s not executing? I see it says “Thread #1”. Is that the main thread? I don’t use VSCode so maybe it’s related to that.

Could this simply be it not correctly debugging? I presume those other threads are all paused.

Well the problem isn’t really about the debugging, but I’m getting the same result in VS2019.

7965249--1021230--upload_2022-3-15_15-19-27.png

The next line of code (185 in this case) simply does not run.
But if I comment out the previous line
//EditorGUILayout.BeginHorizontal();
(and the EndHorizontal call)
then everything works fine.

I’m not sure what’s going on for you.

One observation and I’m not UI expert but AFAIK you cannot just return out of the function like that leaving the layout stuff hanging. You need to end the horizontal etc. I’m not sure what the effects would be for that.