Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
UnitySceneRepacker
Library mod for loading game objects from other unity games
| Last updated | 9 hours ago |
| Total downloads | 96 |
| Total rating | 0 |
| Categories | Libraries |
| Dependency string | jakobhellermann-UnitySceneRepacker-0.2.0 |
| Dependants | 1 other package depends on this package |
This mod requires the following mods to function
BepInEx-BepInExPack_Silksong
BepInEx modloader. Preconfigured and ready to use.
Preferred version: 5.4.2304README
Unity Scene Repacker
Bindings for unity-scene-repacker, allowing you to repack and instantiate objects from other unity games.
Setup
You can reference the package without shipping the assemblies, since they come distributed as the dependency:
<PackageReference Include="Silksong.UnitySceneRepacker" Version="0.1.0" ExcludeAssets="runtime"/>
[package.dependencies]
jakobhellermann-UnitySceneRepacker = "0.1.0"
Example usage:
using System;
using System.Collections;
using BepInEx;
using BepInEx.Configuration;
using UnityEngine;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnitySceneRepacker;
namespace ExampleMod.Source;
[BepInAutoPlugin("io.github.yourgithubusername.examplemod")]
[BepInDependency(UnitySceneRepackerPlugin.Id)]
public partial class ExampleModPlugin : BaseUnityPlugin {
private ConfigEntry<KeyboardShortcut> spawnShortcut = null!;
private RepackedAssets? hollowKnightAssets;
private RepackedAsset? tiktikAsset;
private AsyncOperationHandle<GameObject> tiktikPrefab;
private void Awake() {
try {
spawnShortcut = Config.Bind("Shortcuts", "Spawn Tiktik", new KeyboardShortcut(KeyCode.F2));
hollowKnightAssets = UnitySceneRepackerPlugin.RepackedAssets(
UnitySceneRepackerPlugin.NextToThisGame("Hollow Knight"),
"examplemod"
);
tiktikAsset = hollowKnightAssets.Request("Tutorial_01", "_Enemies/Crawler 2");
} catch (Exception e) {
Logger.LogInfo($"Plugin {Name} ({Id}) failed to initialize: {e}");
}
}
private void Start() {
// optional: start repacking requests. Alternative, the first load will perform and wait for the repack.
hollowKnightAssets?.Prepare();
}
private void Update() {
if (spawnShortcut.Value.IsDown()) StartCoroutine(SpawnTiktik());
}
private IEnumerator SpawnTiktik() {
if (!HeroController.instance) yield break;
Log.Info("Spawning tiktik");
if (!tiktikPrefab.IsValid()) tiktikPrefab = tiktikAsset!.Load();
yield return tiktikPrefab;
Instantiate(tiktikPrefab.Result, HeroController.instance.transform.position, Quaternion.identity);
}
private void OnDestroy() {
hollowKnightAssets?.Dispose();
Log.Info($"Plugin {Name} ({Id}) has been unloaded!");
}
}
Missing scripts
Scripts that don't exist in silksong can be remapped to other scripts, in vanilla or a mod. Fields of the expected name can be deserialized.
UnitySceneRepackerPlugin.RemapScript("Assembly-CSharp", "EnemyHitEffectsUninfected", "Assembly-CSharp", "EnemyHitEffectsRegular");
UnitySceneRepackerPlugin.RemapScript("Assembly-CSharp", "EnemyDreamnailReaction", typeof(DreamnailReactionBridge));
public class DreamnailReactionBridge : MonoBehaviour {
[SerializeField] private int convoAmount;
[SerializeField] private string convoTitle = "";
private void Awake() => Debug.Log($"{name} has {convoAmount} dream nail texts {convoTitle}");
}