/// <summary> /// Creates a cached ReorderableList that can be used on a IList. The serializedProperty passed is used for look-up and is not used in the ReorderableList itself. /// </summary> /// <param name="memberList"></param> /// <param name="tokenProperty"></param> /// <param name="drawHeaderCallback"></param> /// <param name="drawElementCallback"></param> /// <param name="onAddCallback"></param> /// <param name="onRemoveCallback"></param> /// <param name="onSelectCallback"></param> /// <param name="onChangedCallback"></param> /// <param name="onReorderCallback"></param> /// <param name="onCanRemoveCallback"></param> /// <param name="onAddDropdownCallback"></param> /// <returns></returns> public static CachedReorderableList GetListDrawer(System.Collections.IList memberList, SerializedProperty tokenProperty, ReorderableList.HeaderCallbackDelegate drawHeaderCallback, ReorderableList.ElementCallbackDelegate drawElementCallback, ReorderableList.AddCallbackDelegate onAddCallback = null, ReorderableList.RemoveCallbackDelegate onRemoveCallback = null, ReorderableList.SelectCallbackDelegate onSelectCallback = null, ReorderableList.ChangedCallbackDelegate onChangedCallback = null, ReorderableList.ReorderCallbackDelegate onReorderCallback = null, ReorderableList.CanRemoveCallbackDelegate onCanRemoveCallback = null, ReorderableList.AddDropdownCallbackDelegate onAddDropdownCallback = null) { if (memberList == null) { throw new System.ArgumentNullException("memberList"); } if (tokenProperty == null) { throw new System.ArgumentNullException("property"); } int hash = PropertyHandlerCache.GetIndexRespectingPropertyHash(tokenProperty); CachedReorderableList lst; if (_lstCache.TryGetValue(hash, out lst)) { lst.ReInit(memberList); } else { lst = new CachedReorderableList(memberList); _lstCache[hash] = lst; } lst.drawHeaderCallback = drawHeaderCallback; lst.drawElementCallback = drawElementCallback; lst.onAddCallback = onAddCallback; lst.onRemoveCallback = onRemoveCallback; lst.onSelectCallback = onSelectCallback; lst.onChangedCallback = onChangedCallback; lst.onReorderCallback = onReorderCallback; lst.onCanRemoveCallback = onCanRemoveCallback; lst.onAddDropdownCallback = onAddDropdownCallback; return(lst); }
public static CachedReorderableList GetListDrawer(SerializedProperty property, ReorderableList.HeaderCallbackDelegate drawHeaderCallback, ReorderableList.ElementCallbackDelegate drawElementCallback, ReorderableList.AddCallbackDelegate onAddCallback = null, ReorderableList.RemoveCallbackDelegate onRemoveCallback = null, ReorderableList.SelectCallbackDelegate onSelectCallback = null, ReorderableList.ChangedCallbackDelegate onChangedCallback = null, ReorderableList.ReorderCallbackDelegate onReorderCallback = null, ReorderableList.CanRemoveCallbackDelegate onCanRemoveCallback = null, ReorderableList.AddDropdownCallbackDelegate onAddDropdownCallback = null) { if (property == null) { throw new System.ArgumentNullException("property"); } if (!property.isArray) { throw new System.ArgumentException("SerializedProperty must be a property for an Array or List", "property"); } int hash = PropertyHandlerCache.GetIndexRespectingPropertyHash(property); CachedReorderableList lst; if (_lstCache.TryGetValue(hash, out lst)) { lst.ReInit(property.serializedObject, property); } else { lst = new CachedReorderableList(property.serializedObject, property); _lstCache[hash] = lst; } lst.drawHeaderCallback = drawHeaderCallback; lst.drawElementCallback = drawElementCallback; lst.onAddCallback = onAddCallback; lst.onRemoveCallback = onRemoveCallback; lst.onSelectCallback = onSelectCallback; lst.onChangedCallback = onChangedCallback; lst.onReorderCallback = onReorderCallback; lst.onCanRemoveCallback = onCanRemoveCallback; lst.onAddDropdownCallback = onAddDropdownCallback; return(lst); }