SkyrimForge.PrismaUi

SkyrimForge.PrismaUi lets a SkyrimForge plugin create and script Prisma UI views in C#. Prisma UI renders HTML, CSS, and JavaScript over the game.

Requirements to Run

A player needs SkyrimForge, Prisma UI, and SkyrimForge.PrismaUi, which contains the binding and its native shim. A player also needs Media Keys Fix for text input in a page, except on Skyrim VR. Views explains why.

Without Prisma UI, the PrismaUiApi constructor throws an InvalidOperationException whose message states the cause.

Creating a Plugin

A plugin references the SkyrimForge.PrismaUi NuGet package, which depends on the SkyrimForge package:

<PackageReference Include="SkyrimForge.PrismaUi" Version="0.3.0" />

A plugin declares PrismaUiApi as a constructor parameter:

using SkyrimForge;
using SkyrimForge.Events;
using SkyrimForge.PrismaUi;

namespace ViewPlugin;

public sealed class ViewPlugin(PrismaUiApi prisma, IGameEvents events) : IPlugin
{
    public void Start()
    {
        events.OnInputLoaded.Subscribe(_ => prisma.CreateView("view-plugin/index.html"));
    }
}

CreateView throws an InvalidOperationException if Prisma UI creates no view, and CreateViewOrNull returns null instead.

Create a view from OnInputLoaded or later, never from Start. Prisma UI initializes on the first view in the process and requires the game's input device manager, which does not exist during Start. Prisma UI does not retry, so a view created too early affects every mod that uses Prisma UI in that session.

The path is relative to Data\PrismaUI\views, so this mod ships its page as PrismaUI\views\view-plugin\index.html. Views covers scripting a view and receiving calls from its page.

The SkyrimForge.PrismaUi.PluginTemplate package creates a plugin with a page:

dotnet new install SkyrimForge.PrismaUi.PluginTemplate
dotnet new skyrimforge-prisma-ui-plugin --name <YourPluginName>

A project with pages in PrismaUI\views has them copied to the build output and to the folder SkyrimForgeDeployDirectory names.