Initial commit

This commit is contained in:
msk
2022-01-22 20:13:49 -08:00
parent f9d23e5bcf
commit 687473573d
878 changed files with 70957 additions and 0 deletions
@@ -0,0 +1,106 @@
using System;
using UnityEngine;
using UnityEditor;
using UnityEngine.Assertions;
using System.Collections.Generic;
using System.Linq;
using UnityEditor.IMGUI.Controls;
namespace AssetBundleBrowser.AssetBundleDataSource
{
internal class AssetDatabaseABDataSource : ABDataSource
{
public static List<ABDataSource> CreateDataSources()
{
AssetDatabaseABDataSource op = new AssetDatabaseABDataSource();
List<ABDataSource> retList = new List<ABDataSource>();
retList.Add(op);
return retList;
}
public string Name
{
get { return "Default"; }
}
public string ProviderName
{
get { return "Built-in"; }
}
public string[] GetAssetPathsFromAssetBundle(string assetBundleName)
{
return AssetDatabase.GetAssetPathsFromAssetBundle(assetBundleName);
}
public string GetAssetBundleName(string assetPath)
{
AssetImporter importer = AssetImporter.GetAtPath(assetPath);
if (importer == null) return string.Empty;
string bundleName = importer.assetBundleName;
if (importer.assetBundleVariant.Length > 0) bundleName = bundleName + "." + importer.assetBundleVariant;
return bundleName;
}
public string GetImplicitAssetBundleName(string assetPath)
{
return AssetDatabase.GetImplicitAssetBundleName(assetPath);
}
public string[] GetAllAssetBundleNames()
{
return AssetDatabase.GetAllAssetBundleNames();
}
public bool IsReadOnly()
{
return false;
}
public void SetAssetBundleNameAndVariant(string assetPath, string bundleName, string variantName)
{
AssetImporter.GetAtPath(assetPath).SetAssetBundleNameAndVariant(bundleName, variantName);
}
public void RemoveUnusedAssetBundleNames()
{
AssetDatabase.RemoveUnusedAssetBundleNames();
}
public bool CanSpecifyBuildTarget
{
get { return true; }
}
public bool CanSpecifyBuildOutputDirectory
{
get { return true; }
}
public bool CanSpecifyBuildOptions
{
get { return true; }
}
public bool BuildAssetBundles(ABBuildInfo info)
{
if (info == null)
{
Debug.Log("Error in build");
return false;
}
AssetBundleManifest buildManifest = BuildPipeline.BuildAssetBundles(info.outputDirectory, info.options, info.buildTarget);
if (buildManifest == null)
{
Debug.Log("Error in build");
return false;
}
foreach (string assetBundleName in buildManifest.GetAllAssetBundles())
if (info.onBuild != null)
info.onBuild(assetBundleName);
return true;
}
}
}