Attn: Mod Devs - Displaying your own icons

Updated 2 days ago

Invoking Icons

To show your own icons from your own mods it's very simple to use.

Inside your GetHoverText patch or Update loop send a message to the Valheim Hud with a list of prefab names or icon sprites that you want to display as HoverIcons.

// yourData[] can be an array of:
// - Icons: Sprite[]
// - ItemPrefabNames: string[]
// - Tuples Style 1: (Sprite Icon, string Label)[]
// - Tuples Style 2: (string ItemPrefabName, string Label)[]
// NOTE: you can put null in an array Icon or ItemPrefabName to skip a position. 
// You can not put null for the entire tuple.
// Anything beyond 5 elements will be ignored, it will not error if you go beyond the limit.

Hud.instance.SendMessage("UpdateHoverIcons", yourData[], SendMessageOptions.DontRequireReceiver);

NOTE: It will only display 5 icons max. Anymore than that and horizontal width is ugly. 4 is the ideal soft max. Best if you keep it 4 or under. However, 5 is there just in case. Generally a good idea to not clutter the UI.