Silksong.CanvasUtil 1.0.0

dotnet add package Silksong.CanvasUtil --version 1.0.0
                    
NuGet\Install-Package Silksong.CanvasUtil -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Silksong.CanvasUtil" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Silksong.CanvasUtil" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Silksong.CanvasUtil" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Silksong.CanvasUtil --version 1.0.0
                    
#r "nuget: Silksong.CanvasUtil, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Silksong.CanvasUtil@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Silksong.CanvasUtil&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Silksong.CanvasUtil&version=1.0.0
                    
Install as a Cake Tool

CanvasUtil

A utility for making in-game UIs in Hollow Knight: Silksong. This is a direct port of the CanvasUtil library from the Hollow Knight Modding API.

If you are not planning to resize panels, then this should be fairly straightforward to use. Typically you will start by creating a whole-screen canvas with something like

GameObject canvas = CanvasUtil.CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920, 1080));

Note that CanvasUtil.CanvasUtil appears at the start with CanvasUtil repeated. You may want to put something like using CUtil = CanvasUtil.CanvasUtil; at the top of your file, so you can call CUtil.CreateCanvas.

If you have a canvas or panel GameObject parent and you want to add a child panel, then to construct the RectData to pass into the CreatePanel methods:

  • RectSizeDelta should be the size of the child panel.
  • AnchorPivot should represent a point on the parent. The coordinates are from (0, 0) to (1, 1), where (0, 0) is the bottom left corner and (1, 1) is the top right.
  • AnchorMin = AnchorMax, and both should represent a point on the child panel. The coordinates are from (0, 0) to (1, 1), as with the parent.
  • AnchorPosition is the offset from the pivot point on the parent to the anchor point on the child.

For example, to put a child in the bottom-right corner of the parent, you can set the anchor pivot, anchor min and anchor max to (1, 0) - this represents the bottom right corner (max x, min y). The anchor position should be (0, 0) to represent the fact that the anchor pivot (bottom right corner of parent) and anchor (bottom right corner of child) are the same point.

DebugPanel

A utility added to help in mod development. Sometimes you want to know information that may change each frame, so logging is probably not the most helpful way to do it. CanvasUtil provides a utility called DebugPanel to help with this.

The easiest way to do this is to simply do the following:

// In your plugin class, define a function to get the text to display
private static string GetDebugPanelText()
{
    // Code goes here. This function will be called each frame
    // to figure out what the text to display should be.
}

// In your plugin Awake method
CanvasUtil.DebugPanel.Create(GetDebugPanelText);

An alternative approach can be as follows:

// In your plugin class, define a function to update the text and an event raised when updating the text
private static event System.Action<string>? OnUpdateDebugPanelText;
internal static void UpdateDebugPanelText(string newText) => OnUpdateDebugPanelText?.Invoke(newText);

// In your plugin Awake method
var dp = CanvasUtil.DebugPanel.Create();
OnUpdateDebugPanelText += dp.SetText;

// Anywhere else in your mod
MyPlugin.UpdateDebugPanelText("the new text to display");

This is designed to be used while developing mods and is not expected to be used in published versions of mods. In both of the example codes, simply deleting the code from the "In your plugin Awake method" section will stop the debug panel from being created without breaking any other aspect of your mod.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 736 11/24/2025
0.1.1 351 11/9/2025