public static string[] ConvertListToStringArray <T>(IEnumerable <T> list, ToStringMethod <T> method) { string[] ret = new string[list.Count()]; int i = 0; foreach (T obj in list) { ret[i++] = method.Invoke(obj); } return(ret); }
public override void DrawValue(Rect window, float width) { if (OwnerCacheObject.CanWrite) { if (!IsExpanded) { if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) })) { IsExpanded = true; } } else { if (GUILayout.Button("^", new GUILayoutOption[] { GUILayout.Width(25) })) { IsExpanded = false; } } } GUILayout.Label($"<color=#2df7b2>Vector{VectorSize}</color>: {(string)ToStringMethod.Invoke(Value, new object[0])}", new GUILayoutOption[0]); if (OwnerCacheObject.CanWrite && IsExpanded) { GUILayout.EndHorizontal(); var whitespace = CalcWhitespace(window); // always draw x and y GUIHelper.BeginHorizontal(new GUILayoutOption[0]); GUIHelper.Space(whitespace); GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) }); x = GUIHelper.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) }); GUILayout.EndHorizontal(); GUIHelper.BeginHorizontal(new GUILayoutOption[0]); GUIHelper.Space(whitespace); GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) }); y = GUIHelper.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) }); GUILayout.EndHorizontal(); if (VectorSize > 2) { // draw z GUIHelper.BeginHorizontal(new GUILayoutOption[0]); GUIHelper.Space(whitespace); GUILayout.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) }); z = GUIHelper.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) }); GUILayout.EndHorizontal(); } if (VectorSize > 3) { // draw w GUIHelper.BeginHorizontal(new GUILayoutOption[0]); GUIHelper.Space(whitespace); GUILayout.Label("W:", new GUILayoutOption[] { GUILayout.Width(30) }); w = GUIHelper.TextField(w, new GUILayoutOption[] { GUILayout.Width(120) }); GUILayout.EndHorizontal(); } // draw set value button GUIHelper.BeginHorizontal(new GUILayoutOption[0]); GUIHelper.Space(whitespace); if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) })) { SetValueFromInput(); } GUILayout.EndHorizontal(); GUIHelper.BeginHorizontal(new GUILayoutOption[0]); } }