资源导入自动上传提交

dev_chengFeng
DESKTOP-98AVA47\Administrator 2021-07-19 17:48:31 +08:00
parent 2490fbb496
commit 06cf7f6cdd
2 changed files with 114 additions and 59 deletions

View File

@ -21,6 +21,7 @@ namespace GameEditor.Util
string[] usedPath; string[] usedPath;
bool[] usedPathSelect; bool[] usedPathSelect;
string[] filePath; string[] filePath;
List<string> upLoadPathList;
[MenuItem("资源导入/资源导入")] [MenuItem("资源导入/资源导入")]
static void InitWindow() static void InitWindow()
{ {
@ -47,73 +48,100 @@ namespace GameEditor.Util
{ {
EditorGUILayout.BeginVertical(); EditorGUILayout.BeginVertical();
EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginHorizontal();
GUILayout.Label("导入图片"); GUILayout.Label("导入图片");
importTexturePath = GUILayout.TextArea(importTexturePath); importTexturePath = GUILayout.TextArea(importTexturePath);
if (GUILayout.Button("Select", GUILayout.ExpandWidth(false))) if (GUILayout.Button("Select", GUILayout.ExpandWidth(false)))
{
filePath = ProcessUtil.OpenFileWin(importTexturePath, "*.*");
if (filePath != null && filePath.Length > 0)
{ {
filePath = ProcessUtil.OpenFileWin(importTexturePath,"*.*"); importTexturePath = filePath[0];
if (filePath != null && filePath.Length > 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)))
{
upLoadPathList = new List<string>();
string path = "";
for (int i = 0; i < usedPathSelect.Length; i++)
{
if (usedPathSelect[i])
{ {
importTexturePath = filePath[0]; path = usedPath[i];
PlayerPrefs.SetString("ImportResWindow_importTexturePath", importTexturePath);
} }
} }
EditorGUILayout.EndHorizontal(); if (string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(targetPath))
for (int i = 0; i < usedPath.Length; i++)
{ {
usedPathSelect[i] = EditorGUILayout.Toggle(usedPath[i], usedPathSelect[i]); path = targetPath;
} }
ImportTexture(path);
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
GUILayout.Label("导入音频"); if (GUILayout.Button("上传", GUILayout.ExpandWidth(false)))
importAudioPath = GUILayout.TextArea(importAudioPath); {
if (GUILayout.Button("Select", GUILayout.ExpandWidth(false))) string v = "";
for (int i = 0; i < upLoadPathList.Count(); i++)
{ {
filePath = ProcessUtil.OpenFileWin(importTexturePath, "*.*"); if (string.IsNullOrEmpty(v))
if (filePath != null && filePath.Length > 0)
{ {
importTexturePath = filePath[0]; v = upLoadPathList[i];
PlayerPrefs.SetString("ImportResWindow_importTexturePath", importTexturePath); }
else
{
v = v + "," + upLoadPathList[i];
} }
} }
EditorGUILayout.EndHorizontal(); string s = string.Format("/K 一键提交到git.bat {0}", v);
System.Diagnostics.Process.Start("cmd.exe", s);
}
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(); EditorGUILayout.EndVertical();
} }
void SetUpLoadPathList(string subPath)
{
if (upLoadPathList.Contains(subPath))
{
return;
}
upLoadPathList.Add(subPath);
}
void ImportTexture(string path) void ImportTexture(string path)
{ {
if (filePath == null || filePath.Length < 2) if (filePath == null || filePath.Length < 2)
@ -125,6 +153,7 @@ namespace GameEditor.Util
if (!Directory.Exists(fullPath)) if (!Directory.Exists(fullPath))
{ {
Directory.CreateDirectory(fullPath); Directory.CreateDirectory(fullPath);
SetUpLoadPathList(tag1 + "/" + path);
AssetDatabase.Refresh(); AssetDatabase.Refresh();
} }
string desPath = Environment.CurrentDirectory + "/Assets/ImportFloder"; string desPath = Environment.CurrentDirectory + "/Assets/ImportFloder";
@ -154,7 +183,7 @@ namespace GameEditor.Util
{ {
sourceFileName = sourceFileName.Substring(0, sourceFileName.Length - 3); sourceFileName = sourceFileName.Substring(0, sourceFileName.Length - 3);
} }
string[] guids = AssetDatabase.FindAssets(sourceFileName + " t:Texture",new string[] { tag1 }); string[] guids = AssetDatabase.FindAssets(sourceFileName + " t:Texture", new string[] { tag1 });
bool isReplace = false; bool isReplace = false;
if (guids != null && guids.Length > 0) if (guids != null && guids.Length > 0)
@ -176,11 +205,14 @@ namespace GameEditor.Util
if (sourceExt == desExt) if (sourceExt == desExt)
{ {
AssetDatabase.CopyAsset("Assets/ImportFloder/" + fileName, desFilePath); AssetDatabase.CopyAsset("Assets/ImportFloder/" + fileName, desFilePath);
SetUpLoadPathList(desFilePath);
} }
else else
{ {
AssetDatabase.MoveAssetToTrash(desFilePath); AssetDatabase.MoveAssetToTrash(desFilePath);
SetUpLoadPathList(desFilePath);
AssetDatabase.MoveAsset("Assets/ImportFloder/" + fileName, rootPath + "/" + fileName); AssetDatabase.MoveAsset("Assets/ImportFloder/" + fileName, rootPath + "/" + fileName);
SetUpLoadPathList(rootPath + "/" + sourceFileName);
} }
} }
} }
@ -189,6 +221,7 @@ namespace GameEditor.Util
if (!isReplace) if (!isReplace)
{ {
AssetDatabase.MoveAsset("Assets/ImportFloder/" + fileName, Path.Combine(tag1, path) + "/" + fileName); AssetDatabase.MoveAsset("Assets/ImportFloder/" + fileName, Path.Combine(tag1, path) + "/" + fileName);
SetUpLoadPathList(Path.Combine(tag1, path) + "/" + sourceFileName);
} }
} }
AssetDatabase.StopAssetEditing(); AssetDatabase.StopAssetEditing();
@ -196,7 +229,7 @@ namespace GameEditor.Util
AssetDatabase.Refresh(); AssetDatabase.Refresh();
if (Directory.Exists(desPath)) if (Directory.Exists(desPath))
{ {
Directory.Delete(desPath,true); Directory.Delete(desPath, true);
AssetDatabase.Refresh(); AssetDatabase.Refresh();
} }
Debug.Log("导入完成"); Debug.Log("导入完成");

View File

@ -0,0 +1,22 @@
@echo off
set words=%*
:: 获取当前脚本的路径
cd /d %~dp0
:: 自动提交
git init
for %%i in (%words%) do (
git add %%i*
)
git commit -m "bat批处理自动推送:%date:~0,10%,%time:~0,8%"
:: git commit -m "%commitMessage%"
git push origin master
@echo 已经完成,
SET daoTime=60
:dao
set /a daoTime=daoTime-1
ping -n 2 -w 500 127.1>nul
cls
echo 上传Git完成 ,倒计时退出: %daoTime%
if %daoTime%==0 (exit) else (goto dao)