diff --git a/Assets/ManagedResources/Prefabs/UI/GeneralPanel/GeneralBigPopup.prefab b/Assets/ManagedResources/Prefabs/UI/GeneralPanel/GeneralBigPopup.prefab index 9017bb6d79..9071f4a1c4 100644 --- a/Assets/ManagedResources/Prefabs/UI/GeneralPanel/GeneralBigPopup.prefab +++ b/Assets/ManagedResources/Prefabs/UI/GeneralPanel/GeneralBigPopup.prefab @@ -12166,7 +12166,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: "\u62BD\u52305\u661F\u795E\u5C06\u65F6\uFF0C\u670950%\u51E0\u7387\u8F6C\u5316\u4E3A\u5FC3\u613F\u795E\u5C06\uFF01" + m_Text: "\u62BD\u52305\u661F\u795E\u5C06\u65F6\uFF0C\u670940%\u51E0\u7387\u8F6C\u5316\u4E3A\u5FC3\u613F\u795E\u5C06\uFF01" LanguageIndex: 0 --- !u!1 &7349818788191680945 GameObject: diff --git a/Assets/Scripts/Editor/GameEditor/FrameTool/ImportResWindow.cs b/Assets/Scripts/Editor/GameEditor/FrameTool/ImportResWindow.cs new file mode 100644 index 0000000000..a84cb8749b --- /dev/null +++ b/Assets/Scripts/Editor/GameEditor/FrameTool/ImportResWindow.cs @@ -0,0 +1,201 @@ +using LitJson; +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using UnityEditor; +using UnityEngine; +using UnityEngine.Networking; + +namespace GameEditor.Util +{ + public class ImportResWindow : EditorWindow + { + string tag = Environment.CurrentDirectory; + string tag1 = "Assets/ManagedResources"; + string importTexturePath; + string importAudioPath; + string targetPath; + string[] usedPath; + bool[] usedPathSelect; + string[] filePath; + [MenuItem("资源导入/资源导入")] + static void InitWindow() + { + // Get existing open window or if none, make a new one: + ImportResWindow window = (ImportResWindow)EditorWindow.GetWindow(typeof(ImportResWindow)); + window.InitData(); + window.Show(); + } + void InitData() + { + importAudioPath = PlayerPrefs.GetString("ImportResWindow_importAudioPath"); + importTexturePath = PlayerPrefs.GetString("ImportResWindow_importTexturePath"); + targetPath = PlayerPrefs.GetString("ImportResWindow_targetPath"); + usedPath = new string[] { + "ArtFont_en","ArtFont_vi","Icon/FaBao","Icon/Hero","Icon/Item","Icon/SkillIcon","Icon/Pokemon","Icon/ZuoQi","Icons","Icons/SkillIcon","Icons/SoulPrint" + }; + usedPathSelect = new bool[usedPath.Length]; + for (int i = 0; i < usedPath.Length; i++) + { + usedPathSelect[i] = false; + } + } + private void OnGUI() + { + EditorGUILayout.BeginVertical(); + + EditorGUILayout.BeginHorizontal(); + GUILayout.Label("导入图片"); + importTexturePath = GUILayout.TextArea(importTexturePath); + if (GUILayout.Button("Select", GUILayout.ExpandWidth(false))) + { + filePath = ProcessUtil.OpenFileWin(importTexturePath,"*.*"); + if (filePath != null && filePath.Length > 0) + { + importTexturePath = filePath[0]; + PlayerPrefs.SetString("ImportResWindow_importTexturePath", importTexturePath); + } + } + EditorGUILayout.EndHorizontal(); + + for (int i = 0; i < usedPath.Length; i++) + { + usedPathSelect[i] = EditorGUILayout.Toggle(usedPath[i], usedPathSelect[i]); + } + + EditorGUILayout.BeginHorizontal(); + GUILayout.Label("导入音频"); + importAudioPath = GUILayout.TextArea(importAudioPath); + if (GUILayout.Button("Select", GUILayout.ExpandWidth(false))) + { + filePath = ProcessUtil.OpenFileWin(importTexturePath, "*.*"); + if (filePath != null && filePath.Length > 0) + { + importTexturePath = filePath[0]; + PlayerPrefs.SetString("ImportResWindow_importTexturePath", importTexturePath); + } + } + EditorGUILayout.EndHorizontal(); + + + + + EditorGUILayout.BeginHorizontal(); + GUILayout.Label("导入路径"); + GUILayout.Label(tag1); + targetPath = GUILayout.TextArea(targetPath); + if (GUILayout.Button("Brown", GUILayout.ExpandWidth(false))) + { + string path = Path.Combine(tag,tag1) +"/"+ targetPath; + path = EditorUtility.OpenFolderPanel("Resource path", path, "*.*"); + targetPath = path.Replace((Path.Combine(tag, tag1) + "/").Replace("\\","/"), ""); + PlayerPrefs.SetString("ImportResWindow_targetPath", targetPath); + } + if (GUILayout.Button("导入", GUILayout.ExpandWidth(false))) + { + string path = ""; + for (int i = 0; i < usedPathSelect.Length; i++) + { + if (usedPathSelect[i]) + { + path = usedPath[i]; + } + } + if (string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(targetPath)) + { + path = targetPath; + } + ImportTexture(path); + } + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.EndVertical(); + } + void ImportTexture(string path) + { + if (filePath == null || filePath.Length < 2) + { + Debug.LogError("导入文件为空"); + return; + } + string fullPath = Path.Combine(tag, tag1) + "/" + path; + if (!Directory.Exists(fullPath)) + { + Directory.CreateDirectory(fullPath); + AssetDatabase.Refresh(); + } + string desPath = Environment.CurrentDirectory + "/Assets/ImportFloder"; + if (!Directory.Exists(desPath)) + { + Directory.CreateDirectory(desPath); + } + for (int i = 1; i < filePath.Length; i++) + { + string fileName = Path.GetFileName(filePath[i]); + File.Copy(filePath[0] + "/" + filePath[i], desPath + "/" + fileName); + } + AssetDatabase.Refresh(); + + AssetDatabase.StartAssetEditing(); + string[] files = Directory.GetFiles(desPath); + for (int i = 0; i < files.Length; i++) + { + string fileName = Path.GetFileName(files[i]); + string sourceFileName = Path.GetFileNameWithoutExtension(files[i]); + if (sourceFileName.EndsWith("_zh")) + { + sourceFileName = sourceFileName.Substring(0, sourceFileName.Length - 3); + } + string sourceExt = Path.GetExtension(files[i]); + + string[] guids = AssetDatabase.FindAssets(sourceFileName + " t:Texture",new string[] { tag1 }); + if (guids == null || guids.Length < 1) + { + continue; + } + bool isReplace = false; + for (int j = 0; j < guids.Length; j++) + { + string desFilePath = AssetDatabase.GUIDToAssetPath(guids[j]); + string rootPath = Path.GetDirectoryName(desFilePath); + string desfileName = Path.GetFileName(desFilePath); + string desFileNameWithoutExt = Path.GetFileNameWithoutExtension(desFilePath); + if (desFileNameWithoutExt.EndsWith("_zh")) + { + desFileNameWithoutExt = desFileNameWithoutExt.Substring(0, desFileNameWithoutExt.Length - 3); + } + string desExt = Path.GetExtension(desFilePath); + if (sourceFileName == desFileNameWithoutExt) + { + isReplace = true; + if (sourceExt == desExt) + { + AssetDatabase.CopyAsset("Assets/ImportFloder/" + fileName, desFilePath); + } + else + { + AssetDatabase.MoveAssetToTrash(desFilePath); + AssetDatabase.MoveAsset("Assets/ImportFloder/" + fileName, rootPath + "/" + fileName); + } + } + } + if (!isReplace) + { + AssetDatabase.MoveAsset("Assets/ImportFloder/" + fileName, Path.Combine(tag1, path) + "/" + fileName); + } + } + AssetDatabase.StopAssetEditing(); + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + if (Directory.Exists(desPath)) + { + Directory.Delete(desPath,true); + AssetDatabase.Refresh(); + } + Debug.Log("导入完成"); + } + } +} diff --git a/Assets/Scripts/Editor/GameEditor/FrameTool/ImportResWindow.cs.meta b/Assets/Scripts/Editor/GameEditor/FrameTool/ImportResWindow.cs.meta new file mode 100644 index 0000000000..f61ae3bb36 --- /dev/null +++ b/Assets/Scripts/Editor/GameEditor/FrameTool/ImportResWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2d9c1dca6427cd8438ae5f2629ebb5ec +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Editor/Util/ProcessUtil.cs b/Assets/Scripts/Editor/Util/ProcessUtil.cs index a1367c781e..43da873b71 100644 --- a/Assets/Scripts/Editor/Util/ProcessUtil.cs +++ b/Assets/Scripts/Editor/Util/ProcessUtil.cs @@ -101,8 +101,8 @@ namespace GameEditor.Util } System.Diagnostics.Process.Start("notepad.exe", tPath); //用记事本 } - - public static string[] OpenFileWin() + //返回 数组第一个是文件夹路径 ,以后的是文件名字 + public static string[] OpenFileWin(string path,string ext = "*.*") { //初始化 OpenFileName ofn = new OpenFileName(); @@ -112,11 +112,10 @@ namespace GameEditor.Util ofn.maxFile = ofn.file.Length; ofn.fileTitle = new string(new char[64]); ofn.maxFileTitle = ofn.fileTitle.Length; - string path = Application.streamingAssetsPath; path = path.Replace('/', '\\'); ofn.initialDir = path; //默认路径 ofn.title = "Open Project"; - ofn.defExt = "JPG";//显示文件的类型 + ofn.defExt = ext;//显示文件的类型 //注意 一下项目不一定要全选 但是0x00000008项不要缺少 ofn.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;//OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR string[] strs = null; @@ -125,13 +124,21 @@ namespace GameEditor.Util { //多选文件 string[] Splitstr = { "\0" }; - strs = ofn.file.Split(Splitstr, StringSplitOptions.RemoveEmptyEntries); + string[] strs1 = ofn.file.Split(Splitstr, StringSplitOptions.RemoveEmptyEntries); + if (strs1.Length == 1) + { + strs = new string[] { Path.GetDirectoryName(strs1[0]), Path.GetFileName(strs1[0]) }; + } + else + { + strs = strs1; + } } else { Debug.LogFormat("路径为空"); - } + return strs; } }