public void Update() { children.Clear(); var fieldType = GetFieldType(false); if (typeof(UnityEngine.Object).IsAssignableFrom(fieldType) && ReflectionDrawerUtility.TryGetCustomDrawerType(fieldType, fieldInfo == null) == null) { return; } if (value == null) { // Check if we can create a new object of this type // TODO: Move to utility, can be reused - Utility.CanCreateNewObjectOfType if ((fieldType.IsClass && fieldType.IsAbstract == false) || fieldType.IsValueType) { if (fieldType.GetConstructors().Any(o => o.GetParameters().Length == 0)) { value = Activator.CreateInstance(fieldType); NotifyValueChanged(value); } } } var list = new List <FieldInfo>(); ReflectionUtility.GetAllSerializableFieldsInherited(GetFieldType(false), list); if (value != null) { foreach (var field in list) { if (field.FieldType == value.GetType() || field.Name.StartsWith("m_")) { // DevdogLogger.LogWarning("Same type : " + value.GetType()); continue; } var child = ReflectionDrawerUtility.BuildEditorHierarchy(field, value); children.Add(child); } GUI.changed = true; } }
public void Update() { children.Clear(); if (value == null) { value = Array.CreateInstance(fieldInfo.FieldType.GetElementType(), 0); NotifyValueChanged(value); } var arrValue = (Array)value; for (int i = 0; i < arrValue.Length; i++) { var child = ReflectionDrawerUtility.BuildEditorHierarchy(fieldInfo, arrValue, i); children.Add(child); } GUI.changed = true; }