private void AddNewBinding(List <TypeBinding> bindings) { var binding = new TypeBinding(); var view = new BindingView() { Binding = binding }; bindings.Add(binding); _editorViews.Add(view); }
private void DrawBinding(BindingView view) { TypeBinding binding = view.Binding; // Fold EditorGUILayout.BeginHorizontal(); bool isFoldOpen = view.IsFoldOpen; string foldName = _typeDisplayNamesArray[view.TypeIndex]; isFoldOpen = EditorGUILayout.Foldout(isFoldOpen, foldName); view.IsFoldOpen = isFoldOpen; // Add button if (isFoldOpen) { if (GUILayout.Button("Add Target")) { var target = new BindingTarget(); binding.Targets.Add(target); view.TargetViews.Add(new TargetView() { Target = target }); } } if (GUILayout.Button("-", GUILayout.MaxWidth(32))) { _bindingToRemove = view; } EditorGUILayout.EndHorizontal(); // Fold Contents if (isFoldOpen) { // Type selector int oldSelectedIndex = view.TypeIndex; int selectedIndex = EditorGUILayout.Popup( oldSelectedIndex, _typeDisplayNamesArray ); Type bindingType = GetTypeFromIndex(selectedIndex); if (selectedIndex != oldSelectedIndex) { if (bindingType != null) { binding.TypeName = bindingType.AssemblyQualifiedName; } view.TypeIndex = selectedIndex; } ++EditorGUI.indentLevel; if (bindingType != null) { foreach (TargetView targetView in view.TargetViews) { DrawTarget(targetView, bindingType); } } if (_targetToRemove != null) { binding.Targets.Remove(_targetToRemove.Target); view.TargetViews.Remove(_targetToRemove); _targetToRemove = null; } --EditorGUI.indentLevel; EditorGUILayout.Space(); } }