private void OnGUI() { if (GUILayout.Button("Reload")) { } unityPackageScrollViewPos = EditorGUILayout.BeginScrollView(unityPackageScrollViewPos); if (packagePathList != null && packagePathList.Count > 0) { for (int i = 0; i < packagePathList.Count; i++) { packageSelectDic[packagePathList[i]] = GUILayout.Toggle(packageSelectDic[packagePathList[i]], packagePathList[i]); } } EditorGUILayout.EndScrollView(); if (GUILayout.Button("Import")) { for (int i = 0; i < packagePathList.Count; i++) { if (packageSelectDic[packagePathList[i]]) { string assetPath = "Assets";//AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]); Package2Folder.ImportPackageToFolder(packagePathList[i], assetPath, true); //break; } } } }
private static void Paste() { ClipItem item; try { byte[] bytes = Convert.FromBase64String(GUIUtility.systemCopyBuffer); BinaryFormatter formatter = new BinaryFormatter(); using (MemoryStream stream = new MemoryStream(bytes)) { item = formatter.Deserialize(stream) as ClipItem; } } catch (FormatException e) { throw new FormatException("没有从剪切板解析到有效的数据!" + e.Message); } if (item == null) { throw new ArgumentException("没有从剪切板解析到有效的数据!"); } string assetPath = AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]); switch (item.Type) { case ContentType.File: CopyListFileInEditor(item.Values, PathUtil.AssetPath2FullPath(assetPath)); break; case ContentType.Package: if (item.Values.Count > 0 && Path.GetExtension(item.Values[0]).Equals(".unitypackage")) { Package2Folder.ImportPackageToFolder(item.Values[0], assetPath, true); } break; default: break; } }