- Singleton なアクセスを可能にする static アクセサを提供します。
- シンプルな Singleton 機構を作りたかったので作りました。
upm add package dev.upm-packages.singletonNote: upm command is provided by this repository.
You can also edit Packages/manifest.json directly.
$ npm install github:umm/singletonusing UnityEngine;
using UnityModule;
public class SampleSingleton : Singleton<SampleSingleton> {
public string Hoge = "ほげ";
}
public class Sample {
public void Run() {
Debug.Log(SampleSingleton.Instance.Hoge);
}
}Singleton<T>を継承したクラスを作るだけです。<T>には作成するクラスをそのまま用います。
Copyright (c) 2017 Tetsuya Mori
Released under the MIT license, see LICENSE.txt
{ "dependencies": { // (snip) "dev.upm-packages.singleton": "[latest version]", // (snip) }, "scopedRegistries": [ { "name": "Unofficial Unity Package Manager Registry", "url": "https://upm-packages.dev", "scopes": [ "dev.upm-packages" ] } ] }