Skip to main content

C# Client

The plasma.csharp package's Plasma.GameSettings wraps a bounded UTF-8 JSON C ABI in plCSharpPlugin. It exposes typed status and transaction snapshots over the same native service, and native rendering work remains queued rather than executed inline.

Create and dispose clients on the script thread that created them. Owner-associated clients are disposed automatically on component destruction and on managed reload. Dispose them explicitly when a menu closes.

private Plasma.GameSettings? settings;
// During script/menu setup:
settings = new Plasma.GameSettings(this);
settings.StateChanged += state =>
{
// Show state.Message, SecondsRemaining, RestartRequired, and Keep/Revert buttons.
};
var draft = settings.CreateDraft();
draft.SetQualityPreset("high");
draft.FpsCap = 120;
var result = settings.Apply(draft);
// In the script's update: settings.Update();
// Keep button: settings.Confirm(); Cancel/menu close: settings.Dispose();

Building a custom menu​

Describe() returns Values, Confirmed, Defaults, Presets, Descriptors, QualityDescriptors and DisplayModes. This is everything needed to build a menu without hard-coding the control list.

Validate(draft), ResetToDefaults(category) and SetQualityOverride(cvar, value) support custom flows. Numeric and boolean types are validated natively, so a managed menu does not have to duplicate the range rules from Quality Presets.

Update and the revert deadline​

Events are delivered by the client's Update(), so call it from the script update. The native revert deadline does not depend on managed polling: if the script stops updating, a bad display mode still reverts on time.

See Also​