public RListGUI(List <T> items, GUIContent label, ElementGUI elementGUI, ElementHeight height, DefaultElement newItem) : this(items, label, elementGUI, height) { #if UNITY_EDITOR list.onAddCallback = (list) => { items.Insert(items.Count, newItem()); }; #endif }
public RListGUI(List <T> items, GUIContent label, ElementGUI elementGUI, ElementHeight height, Dropdown menu) : this(items, label, elementGUI, height) { #if UNITY_EDITOR list.onAddDropdownCallback = (buttonRect, list) => { menu().Show(Event.current.mousePosition + Event.current.delta); }; #endif }
public static double HeightInCm(ElementHeight height) { switch (height) { case ElementHeight.Small: return 60.0; case ElementHeight.Medium: return 100.0; case ElementHeight.High: return 120.0; default: throw new NotImplementedException(); } }
public static int MaximumNumberOfShelfs(ElementHeight height) { switch (height) { case ElementHeight.Small: return 1; case ElementHeight.Medium: return 3; case ElementHeight.High: return 6; default: throw new NotImplementedException(); } }
public static double HeightInCm(ElementHeight height) { switch (height) { case ElementHeight.Small: return 60.0; case ElementHeight.Medium: return 100.0; case ElementHeight.High: return 120.0; default: throw new NotImplementedException(); } }
public static int MaximumNumberOfShelfs(ElementHeight height) { switch (height) { case ElementHeight.Small: return 1; case ElementHeight.Medium: return 3; case ElementHeight.High: return 6; default: throw new NotImplementedException(); } }
private RListGUI(List <T> items, GUIContent label, ElementGUI elementGUI, ElementHeight height) { #if UNITY_EDITOR list = new UnityEditorInternal.ReorderableList(items, typeof(T), true, true, true, true); list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { if (index >= list.count || list.count <= 0)//Fixes error if .doGUI removes an element from the list { return; } elementGUI(items[index], rect); }; list.elementHeightCallback = (index) => { return(height(items[index])); }; list.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, label, new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter, fontStyle = FontStyle.Bold }); }; list.drawElementBackgroundCallback = (rect, index, active, focused) => { if (list.count <= 0) { return; } rect.height = height(items[index]); Texture2D tex = new Texture2D(1, 1); tex.SetPixel(0, 0, new Color(0.33f, 0.66f, 1f, 0.66f)); tex.Apply(); if (active) { GUI.DrawTexture(rect, tex as Texture); } }; #endif }
public RKnobListGUI(List <T> items, GUIContent label, ElementGUI elementGUI, ElementHeight height, ConnectionKnobs knobs, RepositionKnobs reKnobs, DefaultElement newItem) : this(items, label, elementGUI, height, knobs, reKnobs) { #if UNITY_EDITOR list.onAddCallback = (list) => { items.Insert(items.Count, newItem()); }; #endif }
private RKnobListGUI(List <T> items, GUIContent label, ElementGUI elementGUI, ElementHeight height, ConnectionKnobs knobs, RepositionKnobs reKnobs) { #if UNITY_EDITOR list = new UnityEditorInternal.ReorderableList(items, typeof(T), true, true, true, true); list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { if (index >= list.count || list.count <= 0)//Fixes error if .doGUI removes an element from the list { return; } elementGUI(items[index], rect); if (Event.current.type == EventType.Repaint) { reKnobs(items[index], rect); } }; list.elementHeightCallback = (index) => { return(height(items[index])); }; list.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, label, new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter, fontStyle = FontStyle.Bold }); }; list.drawElementBackgroundCallback = (rect, index, active, focused) => { if (list.count <= 0) { return; } rect.height = height(items[index]); Texture2D tex = new Texture2D(1, 1); tex.SetPixel(0, 0, new Color(0.33f, 0.66f, 1f, 0.66f)); tex.Apply(); if (active) { GUI.DrawTexture(rect, tex as Texture); } }; list.onRemoveCallback = (list) => { foreach (var knob in knobs(items[list.index])) { knob.body.DeleteConnectionPort(knob); } items.RemoveAt(list.index); }; #endif }