using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using MonKey; using UnityEditor; using UnityEngine; namespace BITKit { public partial class BITMonkeyCommands { [Command(nameof(ExportPrefabPreview), "导出已选的预制预览图", QuickName = "exp"), MenuItem("Tools/Export Selected Prefab Preview")] private static void ExportPrefabPreview() { var exportPath = Path.Combine(Application.dataPath, "Temps"); PathHelper.EnsureDirectoryCreated(exportPath); foreach (var image in UnityEditor.Selection.objects.Select(AssetPreview.GetAssetPreview)) { var path = Path.Combine(exportPath, GUID.Generate() + ".png"); File.WriteAllBytes( path, image.EncodeToPNG()); } } } }