private string GetTypeNameForField() { var typeParts = _serializedTypeRef.TypeNameAndAssembly.Split(','); string typeName = typeParts[0].Trim(); if (_showShortName) { typeName = GetShortName(typeName); } if (typeName == string.Empty) { typeName = TypeReference.NoneElement; } else if (TypeCache.GetType(_serializedTypeRef.TypeNameAndAssembly) == null) { _serializedTypeRef.TryUpdatingTypeUsingGUID(); if (TypeCache.GetType(_serializedTypeRef.TypeNameAndAssembly) == null) { typeName += MissingSuffix; } } return(typeName); }
private void DrawTypeReferenceField(Rect position, SerializedProperty property) { var typeOptionsAttribute = attribute as TypeOptionsAttribute ?? new TypeOptionsAttribute(); var serializedTypeRef = new SerializedTypeReference(property); var selectedType = TypeCache.GetType(serializedTypeRef.TypeNameAndAssembly); if (selectedType != null && !typeOptionsAttribute.MatchesRequirements(selectedType)) { Debug.Log($"{property.name} had the {selectedType} value but the type does not match " + "constraints set in the attribute, so it was set to null."); selectedType = null; serializedTypeRef.TypeNameAndAssembly = string.Empty; } var dropdownDrawer = new TypeDropdownDrawer(selectedType, typeOptionsAttribute, fieldInfo?.DeclaringType); var fieldDrawer = new TypeFieldDrawer(serializedTypeRef, position, dropdownDrawer, typeOptionsAttribute.ShortName); fieldDrawer.Draw(); }