public static bool List(Rect position, ref bool showList, ref int listEntry, GUIContent buttonContent, List<string> list, GUIStyle buttonStyle, GUIStyle boxStyle, GUIStyle listStyle, ListCallBack callback, ref bool firstSelected) { if (!firstSelected) { currentPort = list[listEntry]; firstSelected = true; } int controlID = GUIUtility.GetControlID(popupListHash, FocusType.Passive); bool done = false; switch (Event.current.GetTypeForControl(controlID)) { case EventType.mouseDown: if (position.Contains(Event.current.mousePosition)) { buttonContent.text = ""; GUIUtility.hotControl = controlID; showList = true; } break; case EventType.mouseUp: if (showList) { done = true; // Call our delegate method callback(); } break; } GUI.Label(new Rect(position.x, position.y, position.width, 20), currentPort, buttonStyle); Rect listRect = new Rect(position.x, position.y, position.width, list.Count * 20); if (showList) { currentPort = ""; //GUI.Box(listRect, "", boxStyle); var text = list.ToArray(); listEntry = GUI.SelectionGrid(listRect, listEntry, text, 1, listStyle); } if (done) { currentPort = list[listEntry]; showList = false; } return done; }
public static bool List(Rect position, ref bool showList, ref int listEntry, GUIContent buttonContent, object[] list, GUIStyle buttonStyle, GUIStyle boxStyle, GUIStyle listStyle, ListCallBack callBack) { int controlID = GUIUtility.GetControlID(popupListHash, FocusType.Passive); bool done = false; switch (Event.current.GetTypeForControl(controlID)) { case EventType.mouseDown: if (position.Contains(Event.current.mousePosition)) { GUIUtility.hotControl = controlID; showList = true; } break; case EventType.mouseUp: if (showList) { done = true; // Call our delegate method callBack(); } break; } GUI.Label(position, buttonContent, buttonStyle); if (showList) { // Get our list of strings string[] text = new string[list.Length]; // convert to string for (int i = 0; i < list.Length; i++) { text[i] = list[i].ToString(); } Rect listRect = new Rect(position.x, position.y, position.width, list.Length * 20); GUI.Box(listRect, "", boxStyle); listEntry = GUI.SelectionGrid(listRect, listEntry, text, 1, listStyle); } if (done) { showList = false; } return done; }
public static bool List(Rect position, ref bool showList, ref int listEntry, GUIContent buttonContent, GUIContent[] list, GUIStyle buttonStyle, GUIStyle boxStyle, GUIStyle listStyle, ListCallBack callBack) { int controlID = GUIUtility.GetControlID(popupListHash, FocusType.Passive); bool done = false; switch (Event.current.GetTypeForControl(controlID)) { case EventType.mouseDown: if (position.Contains(Event.current.mousePosition)) { GUIUtility.hotControl = controlID; showList = true; } break; case EventType.mouseUp: if (showList) { done = true; if (callBack != null) { callBack(); } } break; } GUI.Label(position, buttonContent, buttonStyle); if (showList) { string[] text = new string[list.Length]; for (int i = 0; i < list.Length; i++) { text[i] = list[i].text; } Rect listRect = new Rect(position.x, position.y, position.width, list.Length * 20); GUI.Box(listRect, "", boxStyle); listEntry = GUI.SelectionGrid(listRect, listEntry, text, 1, listStyle); } if (done) { showList = false; } return(done); }
public static bool List(Rect position, ref bool showList, ref int listEntry, GUIContent buttonContent, GUIContent[] list, GUIStyle listStyle, ListCallBack callBack) { return(List(position, ref showList, ref listEntry, buttonContent, list, "button", "box", listStyle, callBack)); }
public static bool List(Rect position, ref bool showList, ref int listEntry, GUIContent buttonContent, object[] list , GUIStyle listStyle, ListCallBack callBack) { return List(position, ref showList, ref listEntry, buttonContent, list, "button", "box", listStyle, callBack); }
public static bool List(Rect position, ref bool showList, ref int listEntry, GUIContent buttonContent, List<string> list, GUIStyle listStyle, ListCallBack callback, ref bool firstSelected) { return List(position, ref showList, ref listEntry, buttonContent, list, "button", "box", listStyle, callback, ref firstSelected); }