@@ -247,6 +247,8 @@ internal static void ClearStacks()
247247 {
248248 s_PropertyCount = 0;
249249 s_EnabledStack.Clear();
250+ s_IsInsideListStack.Clear();
251+ GUI.isInsideList = false;
250252 s_ChangedStack.Clear();
251253 s_PropertyStack.Clear();
252254 MaterialProperty.ClearStack();
@@ -261,6 +263,7 @@ internal static void ClearStacks()
261263 private static readonly Stack<PropertyGUIData> s_PropertyStack = new Stack<PropertyGUIData>();
262264
263265 private static readonly Stack<bool> s_EnabledStack = new Stack<bool>();
266+ private static readonly Stack<(bool insideList, int depth)> s_IsInsideListStack = new Stack<(bool insideList, int depth)>();
264267
265268 // @TODO: API soon to be deprecated but still in a grace period; documentation states that users
266269 // are encouraged to use EditorGUI.DisabledScope instead. Uncomment next line when appropriate.
@@ -368,6 +371,28 @@ internal static void EndDisabled()
368371 GUI.enabled = s_EnabledStack.Pop();
369372 }
370373
374+ internal static void BeginIsInsideList(int depth)
375+ {
376+ s_IsInsideListStack.Push((GUI.isInsideList, depth));
377+ GUI.isInsideList = true;
378+ }
379+
380+ internal static int GetInsideListDepth()
381+ {
382+ if (s_IsInsideListStack.Count > 0)
383+ return s_IsInsideListStack.Peek().depth;
384+ return -1;
385+ }
386+
387+ internal static void EndIsInsideList()
388+ {
389+ // Stack might have been cleared with ClearStack(), check before pop.
390+ if (s_IsInsideListStack.Count > 0)
391+ GUI.isInsideList = s_IsInsideListStack.Pop().insideList;
392+ else
393+ GUI.isInsideList = false;
394+ }
395+
371396 private static readonly Stack<bool> s_ChangedStack = new Stack<bool>();
372397
373398 public class ChangeCheckScope : GUI.Scope
0 commit comments