mirror of
https://github.com/muskit/H3VR-TNH-Quality-of-Life-Improvements.git
synced 2026-06-02 20:24:26 -07:00
106 lines
3.0 KiB
C#
106 lines
3.0 KiB
C#
|
|
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;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|