void OnGUI() { EditorGUILayout.BeginHorizontal(); slotsSetName = EditorGUILayout.TextField("Slots Set Name:", slotsSetName); if (GUILayout.Button("Save")) { PrefabSpawner2DEditor editor = GetWindow <PrefabSpawner2DEditor>(); string fileName = $"{saveFilePath}{slotsSetName}.json"; Directory.CreateDirectory(saveFilePath); if (!File.Exists(fileName)) { File.Create(fileName).Dispose(); } else { bool confirm = EditorUtility.DisplayDialog("Save Slots", $"The file '{slotsSetName}' already exists.\nDo you want to override it?", "Yes", "No"); if (!confirm) { return; } } File.WriteAllText(fileName, editor.ToJson()); Close(); } EditorGUILayout.EndHorizontal(); }
public static void ShowWindow() { PrefabSpawner2DEditor editor = GetWindow <PrefabSpawner2DEditor>(false, "Prefab Spawner 2D", true); editor.minSize = new Vector2(160, 300); if (File.Exists(defaultSaveFilePath)) { editor.LoadFromJson(new StreamReader(defaultSaveFilePath)); } }