public void Draw(bool parentIncluded, HashSet <string> typeExceptions) { using (new EditorGUI.DisabledScope(!parentIncluded)) { var included = parentIncluded && !typeExceptions.Contains(FullName); using (new GUILayout.HorizontalScope()) { EditorGUILayout.LabelField(m_DisplayName); var indentedRect = EditorGUI.IndentedRect(Rect.zero); var nowIncluded = EditorGUILayout.Toggle("", included, GUILayout.Width(k_ToggleWidth + indentedRect.x)); if (included && !nowIncluded) { typeExceptions.Add(FullName); RuntimeSerializationSettingsUtils.SaveSettings(); } if (!included && nowIncluded) { typeExceptions.Remove(FullName); RuntimeSerializationSettingsUtils.SaveSettings(); } } } }
public void Draw(HashSet <string> assemblyExceptions, HashSet <string> namespaceExceptions, HashSet <string> typeExceptions) { var included = !assemblyExceptions.Contains(FullName); using (new GUILayout.HorizontalScope()) { var wasExpanded = m_Expanded; m_Expanded = EditorGUILayout.Foldout(m_Expanded, DisplayName, true); if (wasExpanded != m_Expanded && Event.current.alt) { m_RootNamespaceGroup.SetExpandedRecursively(m_Expanded); } var indentedRect = EditorGUI.IndentedRect(Rect.zero); var nowIncluded = EditorGUILayout.Toggle("", included, GUILayout.Width(k_ToggleWidth + indentedRect.x)); if (included && !nowIncluded) { assemblyExceptions.Add(FullName); if (Event.current.alt) { m_RootNamespaceGroup.GetAllNamespacesRecursively(namespaceExceptions); } RuntimeSerializationSettingsUtils.SaveSettings(); } if (!included && nowIncluded) { assemblyExceptions.Remove(FullName); if (Event.current.alt) { m_RootNamespaceGroup.RemoveAllNamespacesRecursively(namespaceExceptions); } RuntimeSerializationSettingsUtils.SaveSettings(); } } if (m_Expanded) { using (new EditorGUI.IndentLevelScope()) { using (new EditorGUI.DisabledScope(!included)) { DrawButtons(namespaceExceptions, "namespaces", m_GetAllNamespaces, m_RemoveAllNamespaces); DrawButtons(namespaceExceptions, "types", m_GetAllTypes, m_RemoveAllTypes); } foreach (var kvp in m_RootNamespaceGroup.Children) { kvp.Value.Draw(kvp.Key, included, namespaceExceptions, typeExceptions); } } } }
static void DrawButtons(HashSet <string> exceptions, string type, Action <HashSet <string> > excludeAll, Action <HashSet <string> > includeAll) { using (new GUILayout.HorizontalScope()) { GUILayout.Space(EditorGUI.indentLevel * k_Indent); if (GUILayout.Button($"Exclude all {type}")) { excludeAll(exceptions); RuntimeSerializationSettingsUtils.SaveSettings(); } if (GUILayout.Button($"Include all {type}")) { includeAll(exceptions); RuntimeSerializationSettingsUtils.SaveSettings(); } } }
void Draw(string prefix, string name, bool parentIncluded, HashSet <string> namespaceExceptions, HashSet <string> typeExceptions) { using (new EditorGUI.DisabledScope(!parentIncluded)) { var fullName = name; if (!string.IsNullOrEmpty(prefix)) { fullName = $"{prefix}.{name}"; } var included = parentIncluded && !namespaceExceptions.Contains(fullName); using (new GUILayout.HorizontalScope()) { var wasExpanded = m_Expanded; m_Expanded = EditorGUILayout.Foldout(m_Expanded, name, true); if (wasExpanded != m_Expanded && Event.current.alt) { SetExpandedRecursively(m_Expanded); } var indentedRect = EditorGUI.IndentedRect(Rect.zero); var nowIncluded = EditorGUILayout.Toggle("", included, GUILayout.Width(k_ToggleWidth + indentedRect.x)); if (included && !nowIncluded) { namespaceExceptions.Add(fullName); if (Event.current.alt) { GetAllNamespacesRecursively(prefix, name, namespaceExceptions); GetAllTypesRecursively(typeExceptions); } RuntimeSerializationSettingsUtils.SaveSettings(); } if (!included && nowIncluded) { namespaceExceptions.Remove(fullName); if (Event.current.alt) { RemoveAllNamespacesRecursively(prefix, name, namespaceExceptions); RemoveAllTypesRecursively(typeExceptions); } RuntimeSerializationSettingsUtils.SaveSettings(); } } if (m_Expanded) { using (new EditorGUI.IndentLevelScope()) { using (new EditorGUI.DisabledScope(!included)) { DrawButtons(namespaceExceptions, "namespaces", m_GetAllNamespacesRecursively, m_RemoveAllNamespacesRecursively); DrawButtons(typeExceptions, "types", m_GetAllTypesRecursively, m_RemoveAllTypesRecursively); } foreach (var kvp in m_Children) { kvp.Value.Draw(fullName, kvp.Key, included, namespaceExceptions, typeExceptions); } foreach (var typeRow in m_Types) { typeRow.Draw(included, typeExceptions); } } } } }