sfkbutter-SFK_UILib icon

SFK UILib

UI Library to allow easy creation of various components

Last updated 3 weeks ago
Total downloads 34
Total rating 0 
Categories Libraries
Dependency string sfkbutter-SFK_UILib-1.0.0
Dependants 0 other packages depend on this package

This mod requires the following mods to function

BepInEx-BepInExPack-5.4.2304 icon
BepInEx-BepInExPack

BepInEx pack for Mono Unity games. Preconfigured and ready to use.

Preferred version: 5.4.2304

README

SFK Logo

SFK UILib

A library to allow easy creation of various UI components in game.

Examples

  • Overlays
  • Text
  • Buttons
  • Layouts

This is just a dependency library for developers to use in their mods. It is not a standalone mod.

Code is available on my github. If you have questions or suggestions feel free to reach out of me in the Super Fantasy Kingdom Discord @ButterandCream or raise an issue on github.

All classes use a static factory pattern and have a associated Create method. I tried to chain methods as best as possible with a inheritance hierarchy so everything can be used together.

I also tried to mirror the existing in game components as best as possible, so if you are having trouble figuring out a layout, look in unity explorer

Here is an example snippet

void CreateModsOverlay()
{
    var overlay = UIOverlay.Create(
        "ModsOverlay",
        new Vector2(-300, 0),
        bgMode: OverlayBackgroundMode.PanelFixed,
        bgColor: new Color(0f, 0f, 0f, 0.7f),
        panelSize: new Vector2(300, 400)
        )
        .AddHeader("SFK UILib");

    foreach (var mod in loadedPlugins)
    {
        var t = UIText.Create(
            mod.Value.Metadata.Name,
            overlay.Menu.container.Rect,
            Vector2.zero,
            size: 16,
            alignment: TextAlignmentOptions.TopLeft
        );
        overlay.Menu.Add(t);
    }
}