Home > Back-end >  Loading UI Toolkit assetbundle from Mod
Loading UI Toolkit assetbundle from Mod

Time:01-17

I have written a mod for a video game that has a basic level of mod support, and provides a loader and access to game data etc. Currently the UI for the mod is using the IMGUI and I want to get rid of it.

I've been trying to write a proper UI in Unity, building an assetbundle but am struggling on getting my mod to actually load it.

As a POC I created the exact UI from the manual below, and the C# Script to build the bundle. This works, the manifest file lists my asset inside of the bundle.

https://docs.unity3d.com/Manual/UIE-HowTo-CreateRuntimeUI.html https://docs.unity3d.com/540/Documentation/Manual/BuildingAssetBundles.html

Inside of the game when I try and load this asset from my mod at the most basic level I'm getting an error

Unable to read header from archive file: C:/Test/CustomAsset/customui.assets Failed to read data for the AssetBundle

Script used to load test:

var bundleLoadRequest = AssetBundle.LoadFromFile(
            Path.Combine("C:\\Test\\CustomAsset", "customui.assets")); 
        Log(bundleLoadRequest.GetAllAssetNames().ToString());

I know this path is valid because if I type an invalid path I get a different error "unable to locate asset" or something to that effect. If someone could please assist in pointing me in the right direction

THANKS!

CodePudding user response:

Asset Bundles generally only work for the Unity version they are built with. Is it possible there is a mismatch between your editor version and the version the game you are modding was created with?

Sadly there is no Version check at the beginning that will let you know and they just won’t work.

  • Related