29 lines
1.1 KiB
C#
29 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Runtime.Serialization.Formatters.Binary;
|
|
using UnityEditor;
|
|
|
|
public static class BundleToAssetBuilder
|
|
{
|
|
[MenuItem("Bundle V2/Build Bundle To Asset Data")]
|
|
public static void Build()
|
|
{
|
|
var resourcesDict = new Dictionary<string, LoadAssetBundle.EditorBundleList>();
|
|
var bundles = AssetDatabase.GetAllAssetBundleNames();
|
|
foreach (var bundle in bundles)
|
|
{
|
|
var assets = AssetDatabase.GetAssetPathsFromAssetBundle(bundle)
|
|
.Where(a => a.StartsWith(LoadAssetBundle.assetPathHeader)).Select(a =>
|
|
a.RemoveExtension().Substring(LoadAssetBundle.assetPathHeader.Length + 1)).ToArray();
|
|
if (assets.Length > 0)
|
|
resourcesDict[bundle.RemoveExtension()] = new LoadAssetBundle.EditorBundleList(assets);
|
|
}
|
|
|
|
var bitFormatter = new BinaryFormatter();
|
|
using (var fs = File.Create(EditorCommonUtility.AssetToFilePath(LoadAssetBundle.bundleToAssetPath)))
|
|
{
|
|
bitFormatter.Serialize(fs, resourcesDict);
|
|
}
|
|
}
|
|
} |