private PropertyDrawer GetDrawer(SerializedProperty property) { if (property.propertyType == SerializedPropertyType.Generic || property.propertyType == SerializedPropertyType.ObjectReference) { var fieldInfo = ScriptAttributeUtility.GetFieldInfoFromProperty(property); if (fieldInfo == null) { return(null); } var tp = fieldInfo.FieldType; if (tp.IsListType()) { tp = tp.GetElementTypeOfListType(); } PropertyDrawer drawer = null; if (_fieldTypeToDrawer.TryGetValue(tp, out drawer)) { if (drawer != null) { PropertyDrawerActivator.InitializePropertyDrawer(drawer, null, fieldInfo); } return(drawer); } var drawerType = ScriptAttributeUtility.GetDrawerTypeForType(tp); if (drawerType == null) { _fieldTypeToDrawer[tp] = null; return(null); } drawer = PropertyDrawerActivator.Create(drawerType, null, fieldInfo); _fieldTypeToDrawer[tp] = drawer; return(drawer); } return(null); }
private PropertyDrawer GetDrawer(SerializedProperty property) { if (property.propertyType == SerializedPropertyType.Generic || property.propertyType == SerializedPropertyType.ObjectReference) { var fieldInfo = ScriptAttributeUtility.GetFieldInfoFromProperty(property); if (fieldInfo == null) { return(null); } var tp = fieldInfo.FieldType; if (tp.IsListType()) { tp = tp.GetElementTypeOfListType(); } if (_fieldTypeToDrawer.ContainsKey(tp)) { var result = _fieldTypeToDrawer[tp]; if (result != null) { PropertyDrawerActivator.InitializePropertyDrawer(result, null, fieldInfo); } return(result); } var drawerType = ScriptAttributeUtility.GetDrawerTypeForType(tp); if (drawerType == null) { _fieldTypeToDrawer.Add(tp, null); return(null); } var drawer = PropertyDrawerActivator.Create(drawerType, null, fieldInfo); _fieldTypeToDrawer.Add(tp, drawer); return(drawer); } return(null); }