CrowRx.Singleton 1.0.3

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

CrowRx.Singleton

A lightweight, interface-driven Singleton utility library for Native C# Objects (non-UnityEngine.Object types) in .NET and Unity.

Features

  • Generic Singleton: Provide a simple way to implement the singleton pattern for standard C# classes.
  • Native Object Only: Specifically designed for POCOs (Plain Old CLR Objects), not MonoBehaviour or ScriptableObject.
  • Lifecycle Management: Supports Init() and Release() methods through the IInstance interface.
  • Unity Editor Integration: When running in the Unity Editor, it automatically hooks into the playModeStateChanged event to call Release() and clear the static instance when exiting Play Mode.

Requirements

  • .NET Standard 2.1 compatible environment
  • (Optional) Unity 6.0 or newer for automatic Editor lifecycle management

Installation

Install via NuGet.

Usage

1. Define your Singleton

Inherit from Native<T> and implement the IInstance interface.

using CrowRx.Singleton;

public class MySystem : Native<MySystem>, IInstance
{
    public void Init()
    {
        // Called automatically when the instance is first created
    }

    public void Release()
    {
        // Cleanup logic
    }
}

2. Access the Instance

The instance is lazily initialized on the first access to the Instance property.

// Access the singleton
MySystem.Instance.DoSomething();

// Check if the instance is currently active
if (MySystem.IsValid)
{
    // ...
}

Unity Editor Specific Behavior

While this library works in any .NET environment, it includes specialized behavior for the Unity Editor:

  • When Instance is first accessed in the Editor, it registers a callback to UnityEditor.EditorApplication.playModeStateChanged.
  • When you exit Play Mode, Release() is automatically called on the instance, and the static reference is set to null.
  • This ensures that your singleton state does not persist between Play Mode sessions, preventing common memory leaks and state bugs in Editor tools.
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 (1)

Showing the top 1 NuGet packages that depend on CrowRx.Singleton:

Package Downloads
CrowRx.SingleStream

A Single-Stream utility library for CrowRx. This package is intended for use with Unity3D 6.0 or newer only.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 138 3/11/2026
1.0.2 103 3/3/2026
1.0.1 105 3/3/2026
1.0.0 181 2/19/2026