增加打包自动删除非当前平台的资源包
This commit is contained in:
parent
3de632f811
commit
a49daf71cf
@ -1,6 +1,8 @@
|
|||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using UnityEditor;
|
||||||
using UnityEditor.Build;
|
using UnityEditor.Build;
|
||||||
using UnityEditor.Build.Reporting;
|
using UnityEditor.Build.Reporting;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -26,6 +28,72 @@ public class VirtualFPostProcess : IPostprocessBuildWithReport
|
|||||||
{
|
{
|
||||||
Debug.LogWarning("未找到数据目录: " + dataFolderPath);
|
Debug.LogWarning("未找到数据目录: " + dataFolderPath);
|
||||||
}
|
}
|
||||||
|
DeletAssetBundle(buildOutputPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除不属于当前平台的资源
|
||||||
|
/// </summary>
|
||||||
|
public void DeletAssetBundle(string buildOutPutPath)
|
||||||
|
{
|
||||||
|
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.WebGL)
|
||||||
|
{
|
||||||
|
string path = Path.Combine(buildOutPutPath, "StreamingAssets", "AssetBundles");
|
||||||
|
if (Directory.Exists(path))
|
||||||
|
{
|
||||||
|
string[] allDirectories = Directory.GetDirectories(path);
|
||||||
|
foreach (string dir in allDirectories)
|
||||||
|
{
|
||||||
|
string dirName = Path.GetFileName(dir);
|
||||||
|
if (!dirName.Equals("WebGL", StringComparison.OrdinalIgnoreCase)) // 忽略大小写
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Directory.Delete(dir, true);
|
||||||
|
Debug.Log($"Deleted directory: {dir}");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError($"Failed to delete {dir}: {e.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError($"Directory not found: {path}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows|| EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64)
|
||||||
|
{
|
||||||
|
string path = Path.Combine(buildOutPutPath, "VirtualFramwork_Data", "StreamingAssets", "AssetBundles");
|
||||||
|
if (Directory.Exists(path))
|
||||||
|
{
|
||||||
|
string[] allDirectories = Directory.GetDirectories(path);
|
||||||
|
foreach (string dir in allDirectories)
|
||||||
|
{
|
||||||
|
string dirName = Path.GetFileName(dir);
|
||||||
|
if (!dirName.Equals("Windows", StringComparison.OrdinalIgnoreCase)) // 忽略大小写
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Directory.Delete(dir, true);
|
||||||
|
Debug.Log($"Deleted directory: {dir}");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError($"Failed to delete {dir}: {e.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError($"Directory not found: {path}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetValidBuildPath(BuildReport report)
|
private string GetValidBuildPath(BuildReport report)
|
||||||
|
|||||||
@ -13,8 +13,11 @@ public class Global : Singleton<Global>
|
|||||||
public XMLTool.AppData appData;
|
public XMLTool.AppData appData;
|
||||||
public Module curModule;
|
public Module curModule;
|
||||||
public Body3D.Body cur3DPart;
|
public Body3D.Body cur3DPart;
|
||||||
|
#if UNITY_WEBGL
|
||||||
|
public static string dataPath = Application.dataPath + "/Data";
|
||||||
|
#else
|
||||||
public static string dataPath = Application.dataPath + "/../Data";
|
public static string dataPath = Application.dataPath + "/../Data";
|
||||||
|
#endif
|
||||||
public static string deviceIconsPath = dataPath + "/DeviceIcons/";
|
public static string deviceIconsPath = dataPath + "/DeviceIcons/";
|
||||||
public static string audioPath = dataPath + "/Audio/";
|
public static string audioPath = dataPath + "/Audio/";
|
||||||
public static string appXmlPath = dataPath + "/App.xml";
|
public static string appXmlPath = dataPath + "/App.xml";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user