mirror of
https://github.com/muskit/H3VR-TNH-Quality-of-Life-Improvements.git
synced 2026-06-02 20:24:26 -07:00
Initial commit
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
using Sodalite;
|
||||
using Sodalite.Api;
|
||||
|
||||
namespace MeatKit
|
||||
{
|
||||
[CreateAssetMenu(menuName = "MeatKit/Build Items/Preload Assets", fileName = "New build item")]
|
||||
public class PreloadAssetsBuildItem : BuildItem
|
||||
{
|
||||
public Object[] Items;
|
||||
|
||||
public override IEnumerable<string> RequiredDependencies
|
||||
{
|
||||
get { return new[] {"nrgill28-Sodalite-1.2.0"}; }
|
||||
}
|
||||
|
||||
public override List<AssetBundleBuild> ConfigureBuild()
|
||||
{
|
||||
List<AssetBundleBuild> bundles = new List<AssetBundleBuild>();
|
||||
|
||||
bundles.Add(new AssetBundleBuild
|
||||
{
|
||||
assetBundleName = BuildWindow.SelectedProfile.PackageName.ToLower() + "_preload",
|
||||
assetNames = Items.Select(AssetDatabase.GetAssetPath).ToArray()
|
||||
});
|
||||
|
||||
return bundles;
|
||||
}
|
||||
|
||||
public override void GenerateLoadAssets(TypeDefinition plugin, ILProcessor il)
|
||||
{
|
||||
#if H3VR_IMPORTED
|
||||
EnsurePluginDependsOn(plugin, SodaliteConstants.Guid, SodaliteConstants.Version);
|
||||
|
||||
// Get some references
|
||||
const BindingFlags publicStatic = BindingFlags.Public | BindingFlags.Static;
|
||||
FieldReference basePath = plugin.Fields.First(f => f.Name == "BasePath");
|
||||
MethodInfo pathCombine = typeof(Path).GetMethod("Combine", publicStatic);
|
||||
MethodInfo sodalitePreloadAllAssets = typeof(GameAPI).GetMethod("PreloadAllAssets", publicStatic);
|
||||
|
||||
// Emit our opcodes
|
||||
il.Emit(OpCodes.Ldsfld, basePath);
|
||||
il.Emit(OpCodes.Ldstr, BuildWindow.SelectedProfile.PackageName.ToLower() + "_preload");
|
||||
il.Emit(OpCodes.Call, plugin.Module.ImportReference(pathCombine));
|
||||
il.Emit(OpCodes.Call, plugin.Module.ImportReference(sodalitePreloadAllAssets));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d18106ea7c52411db45cabd362f21f16
|
||||
timeCreated: 1640061580
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 151c1f5398ee70041a49c417b23f1846, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MeatKit
|
||||
{
|
||||
[CreateAssetMenu(menuName = "MeatKit/Build Items/Store Files", fileName = "New build item")]
|
||||
public class StoreFilesBuildItem : BuildItem
|
||||
{
|
||||
public string BundleName;
|
||||
public Object[] Items;
|
||||
|
||||
public override IEnumerable<string> RequiredDependencies
|
||||
{
|
||||
get { return new string[0]; }
|
||||
}
|
||||
|
||||
public override Dictionary<string, BuildMessage> Validate()
|
||||
{
|
||||
var messages = base.Validate();
|
||||
|
||||
if (BundleName != Extensions.MakeValidFileName(BundleName))
|
||||
messages["BundleName"] = BuildMessage.Error("Bundle name contains invalid characters.");
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
public override List<AssetBundleBuild> ConfigureBuild()
|
||||
{
|
||||
List<AssetBundleBuild> bundles = new List<AssetBundleBuild>();
|
||||
|
||||
bundles.Add(new AssetBundleBuild
|
||||
{
|
||||
assetBundleName = BundleName,
|
||||
assetNames = Items.Select(AssetDatabase.GetAssetPath).ToArray()
|
||||
});
|
||||
|
||||
return bundles;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6d6db4144b34551885c304840edfb62
|
||||
timeCreated: 1640061353
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 6fae6dfd178cd184180013acef55632c, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user