public static void DrawAOTList <AOTListType> (string p_labelString, AOTListType p_list, Delegates.FunctionPointer <AOTListType, int> p_onDrawElementFunction, Delegates.FunctionPointer <AOTListType> p_onAddElementFunctions ) where AOTListType : IAOTList { DrawAOTList <AOTListType>(p_labelString, p_list, p_onDrawElementFunction, p_onAddElementFunctions, Vector2.zero, Vector2.zero, false); }
public static Vector2 DrawAOTList <AOTListType> (string p_labelString, AOTListType p_list, Delegates.FunctionPointer <AOTListType, int> p_onDrawElementFunction, Delegates.FunctionPointer <AOTListType> p_onAddElementFunctions, Vector2 p_scrollView, bool p_useScroll = true) where AOTListType : IAOTList { return(DrawAOTList <AOTListType>(p_labelString, p_list, p_onDrawElementFunction, p_onAddElementFunctions, p_scrollView, Vector2.zero, p_useScroll)); }
public static Vector2 DrawAOTList <AOTListType> (string p_labelString, AOTListType p_list, Delegates.FunctionPointer <AOTListType, int> p_onDrawElementFunction, Delegates.FunctionPointer <AOTListType> p_onAddElementFunctions, Vector2 p_scrollView, Vector2 p_initialOffset, bool p_useScroll = true) where AOTListType : IAOTList { Vector2 v_scrollView = p_scrollView; if (p_list != null) { InspectorUtils.BeginContainer(p_initialOffset.x, p_initialOffset.y); p_list.FoldOut = EditorGUILayout.Foldout(p_list.FoldOut, p_labelString); int v_indexToRemove = -1; if (p_list.FoldOut) { EditorGUILayout.BeginHorizontal(); GUILayout.Space(10); EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); GUI.enabled = false; GUILayout.Label("Length", GUILayout.Width(50)); EditorGUILayout.IntField(p_list.Count, GUILayout.Width(80)); GUI.enabled = true; //Add Functions Caller if (InspectorUtils.DrawButton("Add", Color.cyan, GUILayout.Width(50))) { if (p_onAddElementFunctions != null) { p_onAddElementFunctions(p_list); } } EditorGUILayout.EndHorizontal(); //Draw Opener InspectorUtils.DrawTitleText("{", new Color(0.5f, 0.5f, 0.5f)); if (p_useScroll) { v_scrollView = GUILayout.BeginScrollView(p_scrollView); } for (int i = 0; i < p_list.Count; i++) { EditorGUILayout.BeginHorizontal(); GUILayout.Space(10); EditorGUILayout.BeginVertical(); if (p_onDrawElementFunction != null) { p_onDrawElementFunction(p_list, i); } EditorGUILayout.EndVertical(); if (InspectorUtils.DrawButton("X", Color.red, GUILayout.MaxWidth(24), GUILayout.MaxHeight(15))) { v_indexToRemove = i; } EditorGUILayout.EndHorizontal(); } if (p_useScroll) { GUILayout.EndScrollView(); } //Draw Closer InspectorUtils.DrawTitleText("}", new Color(0.5f, 0.5f, 0.5f)); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } //Remove Clicked if (v_indexToRemove >= 0 && v_indexToRemove <= p_list.Count) { p_list.RemoveAt(v_indexToRemove); v_indexToRemove = -1; } InspectorUtils.EndContainer(); } return(v_scrollView); }