public static List <KeyValuePair <int, T> > GenerateIDList <T, T2>(List <T2> baseList) where T : class where T2 : class { int l = baseList.Count; if (l > 0) { if (PropertyUtils.HasProperty <T2>("key") && PropertyUtils.HasProperty <T2>("value")) { List <KeyValuePair <int, T> > list = new List <KeyValuePair <int, T> >(); for (int i = 0; i < l; i++) { T2 obj = baseList[i]; int key = (int)PropertyUtils.GetPropertyValue(obj, "key"); T value = (T)PropertyUtils.GetPropertyValue(obj, "value"); KeyValuePair <int, T> pair = new KeyValuePair <int, T>(key, value); list.Add(pair); } return(list); } else { Debug.LogError("property \"key\" or \"value\" doesn't exist in " + typeof(T2)); return(null); } } else { return(null); } }
/// <summary> /// Find obj by testing a property equality /// </summary> /// <param name="propertyName">Property tested</param> /// <param name="value">Tested value for equality</param> /// <returns></returns> public List <T> Find(string propertyName, object value) { List <T> foundList = new List <T>(); foreach (KeyValuePair <string, T> item in _namedObjs) { if (PropertyUtils.HasProperty <T>(propertyName)) { if (value.Equals(PropertyUtils.GetPropertyValue(item.Value, propertyName))) { foundList.Add(item.Value); } } } return(foundList); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.LabelField(position, label.text, $"{PropertyUtils.GetPropertyValue(property)}"); }