mirror of
https://github.com/muskit/H3VR-TNH-Quality-of-Life-Improvements.git
synced 2026-06-03 04:34:26 -07:00
Initial commit
This commit is contained in:
@@ -0,0 +1,141 @@
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace AssetBundleBrowser.AssetBundleDataSource
|
||||
{
|
||||
/// <summary>
|
||||
/// Build Info struct used by ABDataSource to pass needed build data around.
|
||||
/// </summary>
|
||||
public partial class ABBuildInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Directory to place build result
|
||||
/// </summary>
|
||||
public string outputDirectory
|
||||
{
|
||||
get { return m_outputDirectory; }
|
||||
set { m_outputDirectory = value; }
|
||||
}
|
||||
|
||||
private string m_outputDirectory;
|
||||
|
||||
/// <summary>
|
||||
/// Standard asset bundle build options.
|
||||
/// </summary>
|
||||
public BuildAssetBundleOptions options
|
||||
{
|
||||
get { return m_options; }
|
||||
set { m_options = value; }
|
||||
}
|
||||
|
||||
private BuildAssetBundleOptions m_options;
|
||||
|
||||
/// <summary>
|
||||
/// Target platform for build.
|
||||
/// </summary>
|
||||
public BuildTarget buildTarget
|
||||
{
|
||||
get { return m_buildTarget; }
|
||||
set { m_buildTarget = value; }
|
||||
}
|
||||
|
||||
private BuildTarget m_buildTarget;
|
||||
|
||||
/// <summary>
|
||||
/// Callback for build event.
|
||||
/// </summary>
|
||||
public Action<string> onBuild
|
||||
{
|
||||
get { return m_onBuild; }
|
||||
set { m_onBuild = value; }
|
||||
}
|
||||
|
||||
private Action<string> m_onBuild;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interface class used by browser. It is expected to contain all information needed to display predicted bundle layout.
|
||||
/// Any class deriving from this interface AND implementing CreateDataSources() will be picked up by the browser automatically
|
||||
/// and displayed in an in-tool dropdown. By default, that dropdown is hidden if the browser detects no external data sources.
|
||||
/// To turn it on, right click on tab header "AssetBundles" and enable "Custom Sources"
|
||||
///
|
||||
/// Must implement CreateDataSources() to be picked up by the browser.
|
||||
/// public static List<ABDataSource> CreateDataSources();
|
||||
///
|
||||
/// </summary>
|
||||
public partial interface ABDataSource
|
||||
{
|
||||
//// all derived classes must implement the following interface in order to be picked up by the browser.
|
||||
//public static List<ABDataSource> CreateDataSources();
|
||||
|
||||
/// <summary>
|
||||
/// Name of DataSource. Displayed in menu as "Name (ProvidorName)"
|
||||
/// </summary>
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of provider for DataSource. Displayed in menu as "Name (ProvidorName)"
|
||||
/// </summary>
|
||||
string ProviderName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Array of paths in bundle.
|
||||
/// </summary>
|
||||
string[] GetAssetPathsFromAssetBundle(string assetBundleName);
|
||||
|
||||
/// <summary>
|
||||
/// Name of bundle explicitly associated with asset at path.
|
||||
/// </summary>
|
||||
string GetAssetBundleName(string assetPath);
|
||||
|
||||
/// <summary>
|
||||
/// Name of bundle associated with asset at path.
|
||||
/// The difference between this and GetAssetBundleName() is for assets unassigned to a bundle, but
|
||||
/// residing inside a folder that is assigned to a bundle. Those assets will implicitly associate
|
||||
/// with the bundle associated with the parent folder.
|
||||
/// </summary>
|
||||
string GetImplicitAssetBundleName(string assetPath);
|
||||
|
||||
/// <summary>
|
||||
/// Array of asset bundle names in project
|
||||
/// </summary>
|
||||
string[] GetAllAssetBundleNames();
|
||||
|
||||
/// <summary>
|
||||
/// If this data source is read only.
|
||||
/// If this returns true, much of the Browsers's interface will be disabled (drag&drop, etc.)
|
||||
/// </summary>
|
||||
bool IsReadOnly();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the asset bundle name (and variant) on a given asset
|
||||
/// </summary>
|
||||
void SetAssetBundleNameAndVariant(string assetPath, string bundleName, string variantName);
|
||||
|
||||
/// <summary>
|
||||
/// Clears out any asset bundle names that do not have assets associated with them.
|
||||
/// </summary>
|
||||
void RemoveUnusedAssetBundleNames();
|
||||
|
||||
/// <summary>
|
||||
/// Signals if this data source can have build target set by tool
|
||||
/// </summary>
|
||||
bool CanSpecifyBuildTarget { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Signals if this data source can have output directory set by tool
|
||||
/// </summary>
|
||||
bool CanSpecifyBuildOutputDirectory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Signals if this data source can have build options set by tool
|
||||
/// </summary>
|
||||
bool CanSpecifyBuildOptions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Executes data source's implementation of asset bundle building.
|
||||
/// Called by "build" button in build tab of tool.
|
||||
/// </summary>
|
||||
bool BuildAssetBundles(ABBuildInfo info);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 919244bce66418940b1be40b992ffb7c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace AssetBundleBrowser.AssetBundleDataSource
|
||||
{
|
||||
internal class ABDataSourceProviderUtility
|
||||
{
|
||||
private static List<Type> s_customNodes;
|
||||
|
||||
internal static List<Type> CustomABDataSourceTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (s_customNodes == null) s_customNodes = BuildCustomABDataSourceList();
|
||||
return s_customNodes;
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Type> BuildCustomABDataSourceList()
|
||||
{
|
||||
List<Type> properList = new List<Type>();
|
||||
properList.Add(null); //empty spot for "default"
|
||||
Assembly[] x = AppDomain.CurrentDomain.GetAssemblies();
|
||||
foreach (Assembly assembly in x)
|
||||
try
|
||||
{
|
||||
List<Type> list = new List<Type>(
|
||||
assembly
|
||||
.GetTypes()
|
||||
.Where(t => t != typeof(ABDataSource))
|
||||
.Where(t => typeof(ABDataSource).IsAssignableFrom(t)));
|
||||
|
||||
|
||||
for (int count = 0; count < list.Count; count++)
|
||||
if (list[count].Name == "AssetDatabaseABDataSource")
|
||||
properList[0] = list[count];
|
||||
else if (list[count] != null)
|
||||
properList.Add(list[count]);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//assembly which raises exception on the GetTypes() call - ignore it
|
||||
}
|
||||
|
||||
|
||||
return properList;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8b537f111d73db4dac7f6a47a53b8d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+106
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22084e56372f59e47a3fcd9c3b291923
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user