private bool Draw(FoldoutItem foldout) { if (null != foldout.onBeginDrawFoldout) { foldout.onBeginDrawFoldout.Invoke(foldout.data); } var expanded = EditorGUILayout.Foldout( foldout.isExpanded, foldout.name ); if (null != foldout.onEndDrawFoldout) { foldout.onEndDrawFoldout.Invoke(foldout.data); } if (expanded != foldout.isExpanded) { Expand(foldout, expanded); } if (foldout.isExpanded) { foldout.onDraw?.Invoke(foldout.data); } return(foldout.isExpanded); }
private void Expand(FoldoutItem foldout, bool expanded) { if (expanded != foldout.isExpanded) { if (expanded) { if (exclusive) { foreach (var f in foldouts.Values) { if (f != foldout) { Expand(f, false); } } } foldout.isExpanded = expanded; foldout.onShow?.Invoke(foldout.data); } else { foldout.isExpanded = false; foldout.onHide?.Invoke(foldout.data); } } }
public FoldoutItem Add(string name, T data, Action <T> drawCallback, Action <T> onHide = null, Action <T> onBeginDrawFoldout = null, Action <T> onEndDrawFoldout = null, Action <T> onShow = null) { var foldout = new FoldoutItem() { name = name, data = data, onDraw = drawCallback, onShow = onShow, onHide = onHide, onBeginDrawFoldout = onBeginDrawFoldout, onEndDrawFoldout = onEndDrawFoldout }; foldouts[name] = foldout; foldoutsByData[data] = foldout; return(foldout); }