public static ReorderableList SetHeader(this ReorderableList _list, ReorderableList.HeaderCallbackDelegate _drawHeader) { _list.drawHeaderCallback = _drawHeader; return(_list); }
private void OnEnable() { if (this.target == null) { return; } SerializedObject serializedObject = base.serializedObject; this.atlasName = serializedObject.FindProperty("atlasName"); this.atlasPadding = serializedObject.FindProperty("atlasPadding"); this.atlasSize = serializedObject.FindProperty("atlasSize"); this.fonts = serializedObject.FindProperty("fonts"); this.fontsList = new ReorderableList(serializedObject, this.fonts); ReorderableList arg_6D_0 = this.fontsList; if (delegateA == null) { delegateA = new ReorderableList.HeaderCallbackDelegate(DrawHeader); } arg_6D_0.drawHeaderCallback = delegateA; this.fontsList.elementHeightCallback = new ReorderableList.ElementHeightCallbackDelegate(this.ElementHight); this.fontsList.drawElementCallback = new ReorderableList.ElementCallbackDelegate(this.DrawElement); }
/// <summary> /// Draws the ReorderableList. /// </summary> public static void DrawReorderableList(ref ReorderableList reorderableList, InspectorBase inspector, Array drawnObject, string serializedData, ReorderableList.HeaderCallbackDelegate drawHeaderCallback, ReorderableList.ElementCallbackDelegate drawElementCallback, ReorderableList.ReorderCallbackDelegate reorderCallback, ReorderableList.AddCallbackDelegate addCallback, ReorderableList.RemoveCallbackDelegate removeCallback, ReorderableList.SelectCallbackDelegate selectCallback, Action <int> drawSelectedElementCallback, string key, bool requireOne, bool indentList) { // Initialize the reorder list on first run. if (reorderableList == null) { var data = inspector.PropertyFromName(inspector.serializedObject, serializedData); reorderableList = new ReorderableList(inspector.serializedObject, data, (reorderCallback != null), true, !Application.isPlaying, !Application.isPlaying && (!requireOne || (drawnObject != null && drawnObject.Length > 1))); reorderableList.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, "Name"); }; if (drawHeaderCallback != null) { reorderableList.drawHeaderCallback = drawHeaderCallback; } reorderableList.drawElementCallback = drawElementCallback; if (reorderCallback != null) { reorderableList.onReorderCallback = reorderCallback; } reorderableList.onAddCallback = addCallback; reorderableList.onRemoveCallback = removeCallback; reorderableList.onSelectCallback = selectCallback; if (EditorPrefs.GetInt(key, -1) != -1) { reorderableList.index = EditorPrefs.GetInt(key, -1); } } var listRect = GUILayoutUtility.GetRect(0, reorderableList.GetHeight()); // Indent the list so it lines up with the rest of the content. if (indentList) { listRect.x += InspectorUtility.IndentWidth; listRect.xMax -= InspectorUtility.IndentWidth; } reorderableList.DoList(listRect); if (reorderableList != null && reorderableList.index != -1) { if (drawnObject != null && reorderableList.index < drawnObject.Length) { EditorGUI.indentLevel++; drawSelectedElementCallback(reorderableList.index); EditorGUI.indentLevel--; } } }
public override void OnEnable() { ReorderableList reorderableList = new ReorderableList(new string[0], typeof(string), false, true, false, false); reorderableList.drawElementCallback = new ReorderableList.ElementCallbackDelegate(this.OnDrawSubTrack); ReorderableList arg_4C_0 = reorderableList; if (GroupTrackInspector.< > f__mg$cache0 == null) { GroupTrackInspector.< > f__mg$cache0 = new ReorderableList.HeaderCallbackDelegate(GroupTrackInspector.OnDrawHeader); } arg_4C_0.drawHeaderCallback = GroupTrackInspector.< > f__mg$cache0; reorderableList.showDefaultBackground = true; reorderableList.set_index(0); reorderableList.elementHeight = 20f; this.m_SubTracks = reorderableList; }
public static void DrawReorderableList(ReorderableList list, SerializedProperty property, float?height = null, ReorderableList.HeaderCallbackDelegate drawHeaderCallback = null, ReorderableList.ElementCallbackDelegate drawElementCallback = null) { list.drawHeaderCallback = drawHeaderCallback ?? (rect => { property.arraySize = Mathf.Max(0, EditorGUI.DelayedIntField(rect, "Size", property.arraySize)); }); list.drawElementCallback = drawElementCallback ?? ((rect, index, isActive, isFocused) => { var element = property.GetArrayElementAtIndex(index); rect.y += 2f; EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, height ?? EditorGUIUtility.singleLineHeight), element); }); list.DoLayoutList(); property.serializedObject.TryApplyModifiedProperties(); }
public static CachedReorderableList GetListDrawer(SerializedProperty property, ReorderableList.HeaderCallbackDelegate drawHeaderCallback, ReorderableList.ElementHeightCallbackDelegate getElementHeightCallback, ReorderableList.ElementCallbackDelegate drawElementCallback, ReorderableList.FooterCallbackDelegate drawFooterCallback = null, 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 = GetPropertyHash(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.elementHeightCallback = getElementHeightCallback; lst.drawElementCallback = drawElementCallback; lst.drawFooterCallback = drawFooterCallback; lst.onAddCallback = onAddCallback; lst.onRemoveCallback = onRemoveCallback; lst.onSelectCallback = onSelectCallback; lst.onChangedCallback = onChangedCallback; lst.onReorderCallback = onReorderCallback; lst.onCanRemoveCallback = onCanRemoveCallback; lst.onAddDropdownCallback = onAddDropdownCallback; return(lst); }
/// <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 void DrawReorderableList(ReorderableList list, SerializedProperty property, string label, ref bool unfold, float?height = null, ReorderableList.HeaderCallbackDelegate drawHeaderCallback = null, ReorderableList.ElementCallbackDelegate drawElementCallback = null) => DrawListFolder(label, ref unfold, () => DrawReorderableList(list, property, height, drawHeaderCallback, drawElementCallback));