internal static CustomEditor CreateEditor(ScriptType targetType, bool canUseRefPicker = true) { if (targetType.IsArray) { return(new ArrayEditor()); } var targetTypeType = TypeUtils.GetType(targetType); if (canUseRefPicker) { if (typeof(Asset).IsAssignableFrom(targetTypeType)) { return(new AssetRefEditor()); } if (typeof(FlaxEngine.Object).IsAssignableFrom(targetTypeType)) { return(new FlaxObjectRefEditor()); } } // Use custom editor { var checkType = targetTypeType; do { var type = Internal_GetCustomEditor(checkType); if (type != null) { return((CustomEditor)Activator.CreateInstance(type)); } checkType = checkType.BaseType; // Skip if cannot use ref editors if (!canUseRefPicker && checkType == typeof(FlaxEngine.Object)) { break; } } while (checkType != null); } // Use attribute editor var attributes = targetType.GetAttributes(false); var customEditorAttribute = (CustomEditorAttribute)attributes.FirstOrDefault(x => x is CustomEditorAttribute); if (customEditorAttribute != null) { return((CustomEditor)Activator.CreateInstance(customEditorAttribute.Type)); } // Select default editor (based on type) if (targetType.IsEnum) { return(new EnumEditor()); } if (targetType.IsGenericType) { if (DictionaryEditor.CanEditType(targetTypeType)) { return(new DictionaryEditor()); } // Use custom editor var genericTypeDefinition = targetType.GetGenericTypeDefinition(); var type = Internal_GetCustomEditor(genericTypeDefinition); if (type != null) { return((CustomEditor)Activator.CreateInstance(type)); } } // The most generic editor return(new GenericEditor()); }