Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Latest commit

 

History

History
39 lines (30 loc) · 1.44 KB

File metadata and controls

39 lines (30 loc) · 1.44 KB

Embedded into existing C# Mod

Follow the same steps as with a UI-only mod, except the last step of putting the transpiled file into the game directory. If you haven't followed the steps in UI-only mods, please do so now.

Instead, you should reference the transpiled file inside your mod with the HookLib C# API, and it'll automatically be used when the mod is loaded.

Add HookUILib as a dependency to your project, and then declare the path to your UI and use LoadEmbeddedResource to embed the transpiled code into your mod.

using HookUILib.Core;

namespace MyCoolMod {
    public class Plugin : BaseUnityPlugin {
        private void Awake() {
            Logger.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");
            // [...]
        }
    }
    public class MyCoolModUI : UIExtension {
        public new readonly ExtensionType extensionType = ExtensionType.Panel;
        public new readonly string extensionID = "examples.mycoolmod";

        public MyCoolModUI() {
            this.extensionContent = this.LoadEmbeddedResource("MyCoolMod.dist.mycoolmod.transpiled.js");
        }
    }
}

Important

The string used as the argument is the namespace and the path of your file BUT the / (directory separator) is a . (dot) instead.

Embed the resource via your .csproj file:

<ItemGroup>
    <EmbeddedResource Include="dist/mycoolmod.transpiled.js" />
</ItemGroup>