private void markAdditionsAndRemovals(TypeSelectionNode node) { Type t = node.type; if (t != null && t.IsGenericType && node.children.Count != t.GetGenericArguments().Length) { // Generic types needs to have children to define the generic type argument. _parentsToSetChildren.Add(node); } else if ((t == null || !t.IsGenericType) && node.children.Count != 0) { // Not generic but has children means this node changed to a non-generic from a generic _parentsToClearChildren.Add(node); } }
private TypeSelectionNode getType(TypeSelectionNode node) { if (node.type != null && node.type.IsGenericType) { var types = new Type[node.children.Count]; // Recurse on children until leaves (non-generic types) are reached. int i = 0; foreach (var child in node.children) { types[i++] = getType(child).type; } node.type = node.type.MakeGenericType(types); } // Concrete type, all generic arguments defined by a non-generic type. // Ex) Dictionary<TKey, TValue> becomes Dictionary<int, string> return(node); }
// Recursive drawer that idents children under its parent. private void onGUI(TypeSelectionNode node, int depth) { // Indent based on the depth of the node. EditorGUILayout.BeginHorizontal(); GUILayout.Space(kIndentationWidth * depth); node.OnGUI(); EditorGUILayout.EndHorizontal(); if (node.children.Count > 0) { depth += 1; EditorGUILayout.BeginVertical(); foreach (TypeSelectionNode child in node.children) { onGUI(child, depth); } EditorGUILayout.EndVertical(); } }