Airship
  • Getting Started
    • Welcome to Airship
    • Installing Airship
  • TypeScript
    • Typescript Overview
    • AirshipBehaviour
      • Adding Inspector Properties
      • AirshipSingleton
      • Using Component Decorators
      • Accessing Other Components
      • Lifecycles
  • Networking
    • Multiplayer
    • Local Server Mode
    • Network Signals
    • Network Identity
    • Network Transform
    • Network Functions
  • Publishing
    • Create Dashboard - Game CMS
      • Game Visibility
      • Game Loading Screens
    • Publish Game
    • Publishing with API Key
  • Core Package
    • What is the Core Package?
    • Chat Commands
    • Proximity Prompts
    • Inventory
    • Enable / Disable Core Features
    • Developer Console
  • Platform Services
    • Data Store
      • Locking
    • Cache Store
    • Leaderboards
    • Platform Inventory
    • Server Management
    • Server List
    • Server Transfers
    • Server Messaging
    • Users
    • Parties
    • Matchmaking
    • External Services
  • Unity For Airship
    • Quick Overview
    • DataType Math
    • Random
    • Resources Folder
    • Physics Settings
    • Physics Layers
    • Animation Events
    • User Input
      • Actions
      • Keyboard
      • Mouse
    • Easy Helper Utils
      • Material Color URP
      • Easy Motion
      • Easy Grid Align
      • Easy Look At
      • Easy Shake
      • Easy Destroy
  • Unity Asset Store
  • Packages
    • Import a Package
    • Creating a Package
    • Editing a Package
    • Common Packages
  • CHARACTERS
    • Character System
      • Spawning Characters
      • Custom Character
      • First Person Viewmodel
    • Player System
    • Character Movement System
      • Character Movement Hierarchy
      • Character Movement Physics
      • Character Movement Data
      • Character Movement Events
      • Character Movement Networking
        • Server Authoritative Movement
    • Character Camera
      • Custom Camera Mode
    • Character Animations
      • Character Rig Download
      • Character Ragdoll
  • Accessories
    • Accessories Intro
    • Creating Accessories
    • Using Accessories
  • Optimization
    • Live Game Profiler
    • Reducing Bundle Size
  • Other
    • FAQ
    • JavaScript -> Luau
Powered by GitBook
On this page
  1. TypeScript
  2. AirshipBehaviour

AirshipSingleton

PreviousAdding Inspector PropertiesNextUsing Component Decorators

Last updated 2 months ago

CtrlK

In most games you will want to have some managers that are accessible from anywhere in your codebase. We support this with the AirshipSingleton:

export default class WalletManager extends AirshipSingleton {
    public money = 0;
    // ...
}

An AirshipSingleton inherits from AirshipBehaviour, meaning it can be attached to a Game Object in your scene and expose properties to the inspector. Uniquely, though, it can be used even without being attached to a game object manually.

To grab the instance of a singleton, you can use the static Get method on the Singleton from anywhere in your codebase:

const myMoney = WalletManager.Get().money;

This will find the existing instance (if it exists), or create an instance if it does not.