public Boolean OnInspectorGUI(Boolean isExpaned, Rect position) { if (_styles == null) { _styles = new Styles( ); } position.x += 4; position.width -= 4; var foldoutState = EditorGUI.Foldout(position, isExpaned, String.Format("{0} ({1} items) ", _title, ItemsSource.Count)); position.width /= 2; position.x += position.width; position.width -= 4; var newVal = EditorGUI.ObjectField(position, (UnityEngine.Object)null, typeof(T), true); if (newVal != null) { ItemsSource.Add((T)(System.Object)newVal); BufferItems(); } if (!foldoutState || ItemsSource.Count == 0) { return(foldoutState); } #region | Change Processing | { var hasPreFrameActions = PreFrameActions != null && PreFrameActions.Count > 0; if (hasPreFrameActions) { foreach (var action in PreFrameActions) { action( ); } PreFrameActions.Clear( ); } var hasNextFrameActions = NextFrameActions != null && NextFrameActions.Count > 0; var changed = hasPreFrameActions || hasNextFrameActions; if (ShowDebug) { Debug.Log(String.Format("PreFrame Count: {0}", PreFrameActions.Count)); } if (changed || _viewItems == null || _viewItems.Count <= 0) { BufferItems( ); } if (changed) { foreach (var action in NextFrameActions) { action( ); } NextFrameActions.Clear( ); } } #endregion EditorGUILayout.Space( ); EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); { GUILayout.Space(4f); EditorGUILayout.BeginVertical(new GUILayoutOption[0]); { EditorGUILayout.BeginVertical(_styles.boxBackground); { //_scroll = EditorGUILayout.BeginScrollView(_scroll); //{ var options = new[] { GUILayout.ExpandWidth(true) }; var dragResult = DragGUI <T> .Draggable(GUILayoutUtility.GetRect(10f, 21 * _viewItems.Count, options), 21, (List <T>) _viewItems, _drawElement); if (ShowDebug) { Debug.Log(String.Format("PreFrame Count END: {0}", PreFrameActions.Count)); } if (dragResult.WasMoved) { var newIndex = dragResult.NewIndex.Value; if (ShowDebug) { Debug.Log(String.Format("Trying to move from:{0} to:{1}", dragResult.PreviousIndex, newIndex)); } MoveItemFromTo(dragResult.PreviousIndex, newIndex); //SetIndexAccordingToNeighbors(newIndex); } //} //EditorGUILayout.EndScrollView(); } EditorGUILayout.EndVertical(); //GUILayout.BeginHorizontal(_styles.toolbar, new GUILayoutOption[0]); //{ // GUILayout.FlexibleSpace(); // var iconToolbarPlus = _styles.iconToolbarPlus; // var rect = GUILayoutUtility.GetRect(iconToolbarPlus, _styles.toolbarDropDown); // if (EditorGUIExt.ButtonMouseDown(rect, _styles.iconToolbarClear, FocusType.Native, _styles.toolbarDropDown)) // PreFrameActions.Enqueue(() => ItemsSource.Clear()); //} //GUILayout.EndHorizontal(); } GUILayout.EndVertical( ); GUILayout.Space(4f); } GUILayout.EndHorizontal( ); //GUILayout.FlexibleSpace( ); return(foldoutState); }