90 lines
3.1 KiB
C#
90 lines
3.1 KiB
C#
|
using System;
|
|||
|
using System.IO;
|
|||
|
using System.Linq;
|
|||
|
using Cysharp.Threading.Tasks;
|
|||
|
using Sirenix.OdinInspector;
|
|||
|
using Sirenix.OdinInspector.Editor;
|
|||
|
using UnityEditor;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace HK.Editor
|
|||
|
{
|
|||
|
public class UploadResourcesEditor : OdinEditorWindow
|
|||
|
{
|
|||
|
[MenuItem("Tool/Upload Resources")]
|
|||
|
static void GetWindow()
|
|||
|
{
|
|||
|
// GetWindow<UploadResourcesEditor>().Show();
|
|||
|
var window = GetWindow<UploadResourcesEditor>();
|
|||
|
window.projectName = Application.productName;
|
|||
|
window.version = "v1.0";
|
|||
|
window.serverUrl = "../../../Users/10628/NetworkServer/AssetsFolder";
|
|||
|
window.assetRootFolder = "Bundles/StandaloneWindows/DefaultPackage";
|
|||
|
window.platform = BuildTargetPlatform.StandaloneWindows;
|
|||
|
window.Show();
|
|||
|
}
|
|||
|
|
|||
|
[FolderPath] public string serverUrl;
|
|||
|
[FolderPath] public string assetRootFolder;
|
|||
|
public string projectName;
|
|||
|
public BuildTargetPlatform platform;
|
|||
|
public string version;
|
|||
|
|
|||
|
|
|||
|
[Button("上传资源到本地服务器")]
|
|||
|
public void UploadResources()
|
|||
|
{
|
|||
|
Debug.Log("Upload Resources Start");
|
|||
|
var directories = Directory.GetDirectories(assetRootFolder);
|
|||
|
var strings = directories.OrderByDescending(a => new DirectoryInfo(a).CreationTime).ToArray();
|
|||
|
Debug.Log(strings[0]);
|
|||
|
var paths = Directory.GetFiles(strings[0]);
|
|||
|
|
|||
|
string platformPath = "";
|
|||
|
switch (platform)
|
|||
|
{
|
|||
|
case BuildTargetPlatform.StandaloneWindows:
|
|||
|
platformPath = "PC";
|
|||
|
break;
|
|||
|
case BuildTargetPlatform.StandaloneWindows64:
|
|||
|
platformPath = "PC";
|
|||
|
break;
|
|||
|
case BuildTargetPlatform.Android:
|
|||
|
platformPath = "Android";
|
|||
|
break;
|
|||
|
case BuildTargetPlatform.WebGL:
|
|||
|
platformPath = "WebGL";
|
|||
|
break;
|
|||
|
case BuildTargetPlatform.IOS:
|
|||
|
platformPath = "IOS";
|
|||
|
break;
|
|||
|
case BuildTargetPlatform.StandaloneOSX:
|
|||
|
break;
|
|||
|
case BuildTargetPlatform.StandaloneLinux64:
|
|||
|
break;
|
|||
|
case BuildTargetPlatform.TvOS:
|
|||
|
break;
|
|||
|
case BuildTargetPlatform.PS4:
|
|||
|
break;
|
|||
|
default:
|
|||
|
throw new ArgumentOutOfRangeException();
|
|||
|
}
|
|||
|
|
|||
|
var serverPath = Path.Combine(serverUrl, projectName, platformPath, version);
|
|||
|
if (!Directory.Exists(serverPath))
|
|||
|
{
|
|||
|
Directory.CreateDirectory(serverPath);
|
|||
|
}
|
|||
|
|
|||
|
foreach (var path in paths)
|
|||
|
{
|
|||
|
var fileInfo = new FileInfo(path);
|
|||
|
var combine = Path.Combine(serverPath, fileInfo.Name);
|
|||
|
fileInfo.CopyTo(combine, true);
|
|||
|
}
|
|||
|
|
|||
|
Debug.Log($"Upload Resources version is {strings[0]}");
|
|||
|
Debug.Log("Upload Resources Finished");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|