public static void Popup(DataSaver gameSaves, DataSaverEditor.DataType dataType, Vector2 position, Action onAdd) { DataSaverEditorPopup window = ScriptableObject.CreateInstance <DataSaverEditorPopup>(); window.position = new Rect(position.x, position.y, 250, 88); window.Init(gameSaves, dataType, onAdd); window.ShowPopup(); }
/// <summary> /// Retourne Faux si une key n'existait pas /// </summary> private bool DrawData(DataType type, int keysStart, int keysEnd) { OneWayBool allKeyExist = new OneWayBool(true); EditorGUILayout.BeginHorizontal(); // + Button if (IsDataTypeModifiable(type)) { var p = GUI.skin.button.padding; var o = GUI.skin.button.contentOffset; RectOffset wasPadding = new RectOffset(p.left, p.right, p.top, p.bottom); Vector2 wasContentOffset = new Vector2(o.x, o.y); GUI.skin.button.padding = new RectOffset(0, 0, 0, 0); GUI.skin.button.contentOffset = new Vector2(0, -1); if (GUILayout.Button("+", GUILayout.Width(16), GUILayout.Height(16))) { var screenPoint = GUIUtility.GUIToScreenPoint(Event.current.mousePosition); DataSaverEditorPopup.Popup(gameSaves, type, screenPoint, RefreshKeys); } GUI.skin.button.padding = wasPadding; GUI.skin.button.contentOffset = wasContentOffset; } // Label EditorGUILayout.LabelField(type.ToString(), EditorStyles.boldLabel); EditorGUILayout.EndHorizontal(); // Data if (keysStart == keysEnd) // If length == 0 { EditorGUILayout.LabelField("Empty", EditorStyles.centeredGreyMiniLabel); } else { for (int i = keysStart; i < keysEnd; i++) { allKeyExist.TryToSet(DrawData(type, keys[i])); } } EditorGUILayout.Space(); return(allKeyExist); }