OpenBone.Runtime 0.3.0

dotnet add package OpenBone.Runtime --version 0.3.0
                    
NuGet\Install-Package OpenBone.Runtime -Version 0.3.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="OpenBone.Runtime" Version="0.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OpenBone.Runtime" Version="0.3.0" />
                    
Directory.Packages.props
<PackageReference Include="OpenBone.Runtime" />
                    
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 OpenBone.Runtime --version 0.3.0
                    
#r "nuget: OpenBone.Runtime, 0.3.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 OpenBone.Runtime@0.3.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=OpenBone.Runtime&version=0.3.0
                    
Install as a Cake Addin
#tool nuget:?package=OpenBone.Runtime&version=0.3.0
                    
Install as a Cake Tool

OpenBone.Runtime

The OpenBone runtime for .NET: load .obone and .obonb files and play skeletons, animations and state machines.

OpenBone is open-source 2D skeletal animation: Spine-style rigging and Rive-style interactive state machines. This package is a native C# port of the reference runtime. It covers skeletons, skins, every attachment type, animation mixing, IK, transform, path and physics constraints, particles, sprite sequences, text, packed atlases, state machines, events and audio commands. It passes the cross-language OpenBone conformance suite.

The runtime does not draw anything. Each frame it gives you a draw list (vertices, UVs, triangles, texture, colour, blend mode, clipping), so you can render it with any engine. It targets netstandard2.1 and net8.0 and has no dependencies.

Install

dotnet add package OpenBone.Runtime

Quick start

using OpenBone;

var doc = DocumentLoader.Load(File.ReadAllBytes("knight.obone"));   // or a .obonb file
var hero = new OpenBoneInstance(doc);
hero.Event += e => Console.WriteLine($"event {e.Name} at {e.Time}");
hero.AudioCommand += c => Console.WriteLine($"audio {c.Type} {c.Sound}");

hero.Play("walk");                                      // loops by default

// Once per frame:
hero.Advance(dt);
foreach (var item in hero.DrawList())
{
    // item.Vertices: world x,y pairs (y up)    item.Uvs: 0..1 (v down)    item.Indices: triangles
    // item.Texture: image or atlas page (null = untextured)    item.Color, item.Dark, item.Blend, item.Clip
}

Queue animations and change skins through AnimationState and Skeleton:

hero.Skeleton.SetSkin("default");
hero.Play("attack", loop: false);
hero.AnimationState.AddAnimation(0, "idle", loop: true);

State machines

var button = new OpenBoneInstance(DocumentLoader.Load(File.ReadAllBytes("button.obone")));
var sm = button.UseStateMachine("ui");                  // or UseStateMachine() for the first one
sm.StateChanged += s => Console.WriteLine($"{s.Layer}: {s.From} -> {s.To}");

sm.SetInput("hover", true);
sm.Fire("press");
button.Advance(dt);

// Pointer input for listeners is in skeleton space (y up). Convert from artboard pixels first:
button.ArtboardToSkeleton(px, py, out var x, out var y);
button.Pointer("down", x, y);

Without a script host, scripts attached to the document are skipped and everything else runs.

Main API

Type What it does
DocumentLoader Load(byte[]) reads .obone (JSON) or .obonb (binary) and returns a Document. FromJson(string) reads JSON. Throws OpenBoneFormatException for data that is not an OpenBone document or is a newer version, and OpenBone.Json.JsonException for malformed JSON.
Document The loaded data: artboard size and origin, images, atlas, skeleton, animations, state machines, scripts, audio.
OpenBoneInstance The usual entry point. Play, UseStateMachine, Advance(dt), DrawList(), Pointer, ArtboardToSkeleton, events Event, StateChanged, AudioCommand. OpenBoneInstance.Load(bytes) loads and creates in one call.
AnimationState Tracks and mixing: SetAnimation, AddAnimation (with delay and mix), ClearTrack, ClearTracks.
Skeleton Bones, slots and draw order: FindBone, FindSlot, SetSkin, SetToSetupPose, UpdateWorldTransform, BoundingBoxes().
SkeletonBounds Active bounding boxes of one pose (skeleton space, y up): Boxes, MinX..MaxY, Update, AabbContainsPoint, AabbIntersects, ContainsPoint(All), IntersectsSegment(All), IntersectsBounds(other).
StateMachineInstance SetInput, SetBool, SetNumber, SetString, Fire, SetText, GetInput, ActiveStates, events StateChanged, InputChanged, Event, AudioCommand, Log, Error.
DrawItem One piece of geometry: Vertices, Uvs, Indices, Texture, TextureRect, Color, Colors (per vertex), Dark (two-colour tint), Blend, Clip, Text, Particles.
AudioCommand A sound instruction for your audio backend: Type is play, stop or fade, with the sound id, asset, bus, volume, rate, loop and fade times.
StateMachineOptions Options for state machines: ScriptHost.
IScriptHost Interface for a script engine. OpenBone.Scripting.Jint implements it.

Unity

Unity users should install the com.openbone.runtime package, which includes this runtime plus an importer, components, a mesh generator, a shader and an audio bridge. In the Package Manager, choose Add package from git URL and enter:

https://github.com/UXCentury/open-bone.git#upm

Documentation

License

MIT. Copyright (c) UX Century and OpenBone contributors. See LICENSE.

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 is compatible.  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.
  • .NETStandard 2.1

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on OpenBone.Runtime:

Package Downloads
OpenBone.MonoGame

MonoGame (DesktopGL) integration for the OpenBone C# runtime: renderer (blend modes, clipping, two-colour tint), player component with pointer input, and a SoundEffect bridge for audio commands.

OpenBone.Scripting.Jint

Script host for OpenBone state machines: runs the document's JavaScript in Jint (BSD-2-Clause) with the same ob API, hooks and CPU / memory limits as the reference QuickJS host.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.0 0 11/11/2026