概述
using UnityEngine;
using System.Collections;
using UnityEditor;
using System.IO;
public class Builder {
[MenuItem("Builder/CopyToServer")]
public static void CopyToServer()
{
string folder = Application.streamingAssetsPath;
DirectoryInfo streamingAsset = new DirectoryInfo(folder);
GetDirectory(streamingAsset);
}
public static string serverPath = @"D:wwwStreamingAssets";
public static void GetDirectory(DirectoryInfo direc)
{
string localFolderName = direc.FullName;
string localFolder = localFolderName.Substring(localFolderName.LastIndexOf("StreamingAssets"));
localFolder = localFolder.Replace("StreamingAssets", "");
localFolder = serverPath + "/" + localFolder;
if (!Directory.Exists(localFolder))
Directory.CreateDirectory(localFolder);
FileInfo[] fileInfos = direc.GetFiles();
for (int i = 0; i < fileInfos.Length; i++)
{
string fileFullName = localFolder + "/" + fileInfos[i].Name;
FileInfo file = new FileInfo(localFolder+"/"+fileInfos[i].Name);
if (file.Exists) file.Delete();
fileInfos[i].CopyTo(fileFullName);
Debug.Log(fileFullName);
}
DirectoryInfo[] folders = direc.GetDirectories();
foreach(DirectoryInfo info in folders)
{
GetDirectory(info);
}
}
}
最后
以上就是大气老虎为你收集整理的Unity 文件复制工具的全部内容,希望文章能够帮你解决Unity 文件复制工具所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复