Skip to content
kianzarrin edited this page Feb 28, 2022 · 20 revisions

for external mods that want to register UUI buttons please look at the example mod: https://github.com/kianzarrin/UnifiedUI/blob/master/ExampleMod/ExampleMod.cs#L79.

please contact me on discord to ask about your specific use case.

you can download the library from:

apart from the example mod above and this wiki, each API method has been documented in UnifiedUILib.dll

Button sprites:

Chamelon created some sprites for some mods in here (look for your own mod ID): https://github.com/kianzarrin/UnifiedUI/tree/master/UnifiedUIMod/Resources

Register tool button:

using UnifiedUI.Helpers;
string iconPath =  UserMod.instance.GetFullPath("Resources", "icon.png"); // returns Path/To/Mod/Resources/icon.png
var button = UUIHelpers.RegisterToolButton(
	name: "MyModButton",
	groupName: null, // default group
	tooltip: "some tooltip",
	tool: mytool,
        icon: UUIHelpers.LoadTexture(iconPath),
        hotkeys: new UUIHotKeys { ActivationKey= ModSettings.Hotkey });

How hotkeys work in the example above:

  • pressing the ActivationHotkey enables your mod (your mod should not handle the hotkey anymore).
  • if your tool is active, UUI will prevent other mods from using their activationKey if it collides with your In tool HotKey
  • HotKeys may be modified in UUI, so don't forget to add the following line: UIKeymappingsPanel.cs:27

Register Custom button:

using UnifiedUI.Helpers;
string iconPath =  UserMod.instance.GetFullPath("Resources", "icon.png"); // returns Path/To/Mod/Resources/icon.png
var customButton = UUIHelpers.RegisterCustomButton(
	name: "MyModButton",
	groupName: null, // default group
	tooltip: "some tooltip",
        icon: UUIHelpers.LoadTexture(iconPath),
	onToggle:(value)=> value ? MyWindow.Open() :  MyWindow.Close();
	onToolChanged: null,
        hotkeys: new UUIHotKeys { ActivationKey= ModSettings.Hotkey });

MyWindow.Start() => customButton.IsActive = true;
MyWindow.OnDestroy() => customButton.IsActive = false;

Register hotkeys:

If you do not wish to register button and only wish to register hotkeys.

var activeKeys = new Dictionary<SavedInputKey, Func<bool>>(){
    {hotkey1,()=>true}, 
    {hotkey2,()=>true}, 
}
RegisterHotkeys(
            onToggle: ToggleMod,  
            activationKey: new SavedInputKey(...), 
            activeKeys: activeKeys );
Clone this wiki locally