private static void DisplayArrayKeyPropertyDropdown(Rect rect, string propertyPath, SerializedProperty column, Object referenceObject) { HashSet <string> propertyPaths = new HashSet <string>(); var iterator = new ScriptableObjectPropertyIterator(referenceObject, propertyPath); if (!iterator.IsValid()) { Debug.LogError($"The current reference object {referenceObject} does not contain an array of this type with values in it. Try another reference object."); return; } foreach (SerializedProperty property in iterator) { if (!IsValidPropertyKeyType(property.propertyType)) { continue; } propertyPaths.Add(property.propertyPath.Substring(propertyPath.Length + 1)); // + 1 to skip the '.' } PropertyDropdown dropdown = new PropertyDropdown(new AdvancedDropdownState(), s => { column.FindPropertyRelative("ArrayPropertyKey").stringValue = s; column.serializedObject.ApplyModifiedProperties(); }, propertyPaths, null); dropdown.Show(rect); }
private static void DisplayArrayDrawingPropertyDropdown(Rect rect, string propertyPath, SerializedProperty column, Object referenceObject, HashSet <string> typeStrings) { HashSet <string> propertyPaths = new HashSet <string>(); Dictionary <string, SerializedPropertyType> typeLookup = new Dictionary <string, SerializedPropertyType>(); var iterator = new ScriptableObjectPropertyIterator(referenceObject, propertyPath); if (!iterator.IsValid()) { Debug.LogError($"The current reference object {referenceObject} does not contain an array of this type with values in it. Try another reference object."); return; } foreach (SerializedProperty property in iterator) { if (property.propertyType == SerializedPropertyType.Generic) { continue; } if (!typeStrings?.Contains(property.type) ?? false) { continue; } string localPath = property.propertyPath.Substring(propertyPath.Length + 1); propertyPaths.Add(localPath); // + 1 to skip the '.' typeLookup.Add(localPath, property.propertyType); } PropertyDropdown dropdown = new PropertyDropdown(new AdvancedDropdownState(), s => { column.FindPropertyRelative("ArrayPropertyPath").stringValue = s; column.FindPropertyRelative("ArrayPropertyType").intValue = (int)typeLookup[s]; column.serializedObject.ApplyModifiedProperties(); }, propertyPaths, null); dropdown.Show(rect); }