Skip to content
kianzarrin edited this page Mar 22, 2021 · 20 revisions

for external mods that want to register UUI buttons please look at the example mod. this should be done in LoadingExtension.OnLevelLoaded() to make sure Unified UI is initialized. it would be WRONG to register the UUI button in LoadingManger.m_levelLoaded because that is too early. example code:

using UnifiedUI.Helpers;
sprites =  UserMod.instance.GetFullPath("Resources", "sprites.png"); // returns Path/To/Mod/Resaources/sprites.png
var button = UUIHelpers.RegisterToolButton(
	name: "MyModButton",
	groupName: null, // default group
	tooltip: "some tooltip",
	spritefile: sprites,
	tool: mytool);

// or use this code:

var customButton = UUIHelpers.RegisterToolButton(
	name: "MyModButton",
	groupName: null, // default group
	tooltip: "some tooltip",
	spritefile: sprites, 
	onToggle:(value)=> value ? MyWindow.Open() :  MyWindow.Close();
	onToolChanged: null);

MyWindow.Start() => customButton.IsActive = true;
MyWindow.OnDestroy() => customButton.IsActive = false;
Clone this wiki locally