Rebuild assets and add new editor script
This commit is contained in:
parent
b6f0901063
commit
52a69155bb
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Windows;
|
||||
|
||||
public class HookahAssetBuilder
|
||||
{
|
||||
|
|
@ -15,28 +13,53 @@ public class HookahAssetBuilder
|
|||
static readonly string ModPackProfilePath = $@"{ModManagerProfilesPath}/{ModPackProfileName}";
|
||||
static readonly string ModPackHookahPlacePath = @$"{ModPackProfilePath}/BepInEx/plugins/{ModPackModName}";
|
||||
|
||||
static readonly string ModProjectPath = @"D:\Code\LC-Decompiled\Mods\HookahPlace";
|
||||
static readonly string ModProjectPath = @"D:\Code\LethalCompany\Mods\HookahPlace";
|
||||
static readonly string DllName = "Ratijas.HookahPlace.dll";
|
||||
static readonly string DllSourcePath = $@"{ModProjectPath}/HookahPlace/bin/Debug/netstandard2.1/{DllName}";
|
||||
static readonly string[] DllDestinationPaths = new string[]
|
||||
{
|
||||
// relative to Unity project
|
||||
$@"Assets/LethalCompany/Mods/plugins/HookahPlace/Dependencies/{ModPackModName}",
|
||||
$@"Assets/LethalCompany/Mods/plugins/Dependencies/{ModPackModName}",
|
||||
ModPackHookahPlacePath,
|
||||
};
|
||||
|
||||
static readonly string AssetBundlesPath = "Assets/LethalCompany/Mods/plugins/HookahPlace/AssetBundles";
|
||||
static readonly string[] AssetBundlesNames = new string[]
|
||||
{
|
||||
"hookahplaceasset",
|
||||
"hookahunlockableassets",
|
||||
};
|
||||
static readonly string[] AssetBundlesDestinationPaths = new string[]
|
||||
{
|
||||
@$"{ModPackHookahPlacePath}/Assets",
|
||||
@$"{ModProjectPath}/HookahPlace/res",
|
||||
};
|
||||
|
||||
public static BuildAssetBundlesParameters GetBuildAssetBundlesParameters()
|
||||
{
|
||||
var assetBundleDefinitions = new AssetBundleBuild[]
|
||||
{
|
||||
new AssetBundleBuild()
|
||||
{
|
||||
assetBundleName = "hookahplaceasset",
|
||||
assetNames = new string[]
|
||||
{
|
||||
"Assets/LethalCompany/Mods/plugins/HookahPlace/HookahContentContainer.asset",
|
||||
}
|
||||
},
|
||||
new AssetBundleBuild()
|
||||
{
|
||||
assetBundleName = "hookahunlockableassets",
|
||||
assetNames = new string[]
|
||||
{
|
||||
"Assets/LethalCompany/Mods/plugins/HookahPlace/Content/Unlockables",
|
||||
}
|
||||
},
|
||||
};
|
||||
var buildParameters = new BuildAssetBundlesParameters()
|
||||
{
|
||||
outputPath = AssetBundlesPath,
|
||||
options = BuildAssetBundleOptions.ChunkBasedCompression,
|
||||
bundleDefinitions = assetBundleDefinitions
|
||||
};
|
||||
return buildParameters;
|
||||
}
|
||||
|
||||
[MenuItem("HookahPlace/All")]
|
||||
public static void DoAll()
|
||||
{
|
||||
|
|
@ -82,9 +105,22 @@ public class HookahAssetBuilder
|
|||
{
|
||||
UnityEngine.Debug.Log("Building asset bundles for HookahPlace...");
|
||||
|
||||
Directory.CreateDirectory(AssetBundlesPath);
|
||||
var buildParameters = GetBuildAssetBundlesParameters();
|
||||
Directory.CreateDirectory(buildParameters.outputPath);
|
||||
AssetBundleManifest manifest = BuildPipeline.BuildAssetBundles(buildParameters);
|
||||
|
||||
BuildPipeline.BuildAssetBundles(AssetBundlesPath, BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.StandaloneWindows);
|
||||
if (manifest != null)
|
||||
{
|
||||
foreach(var bundleName in manifest.GetAllAssetBundles())
|
||||
{
|
||||
string projectRelativePath = buildParameters.outputPath + "/" + bundleName;
|
||||
UnityEngine.Debug.Log($"Size of AssetBundle {projectRelativePath} is {new FileInfo(projectRelativePath).Length}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UnityEngine.Debug.Log("Build failed, see Console and Editor log for details");
|
||||
}
|
||||
|
||||
if (Application.isBatchMode)
|
||||
{
|
||||
|
|
@ -97,13 +133,16 @@ public class HookahAssetBuilder
|
|||
{
|
||||
UnityEngine.Debug.Log("Installing asset bundles for HookahPlace...");
|
||||
|
||||
var buildParameters = GetBuildAssetBundlesParameters();
|
||||
|
||||
foreach (var destinationPath in AssetBundlesDestinationPaths)
|
||||
{
|
||||
Directory.CreateDirectory(destinationPath);
|
||||
|
||||
foreach (var name in AssetBundlesNames)
|
||||
foreach (var bundle in buildParameters.bundleDefinitions)
|
||||
{
|
||||
var sourceFileName = $"{AssetBundlesPath}/{name}";
|
||||
var name = bundle.assetBundleName;
|
||||
var sourceFileName = $"{buildParameters.outputPath}/{name}";
|
||||
var destFileName = $"{destinationPath}/{name}";
|
||||
FileCopy(sourceFileName, destFileName);
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue