# @umm/setting_core

> Core module for ***Setting.asset

Latest version **1.1.0** (published 2017-10-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @umm/setting_core
pnpm add @umm/setting_core
yarn add @umm/setting_core
bun add @umm/setting_core
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2017-10-20 |
| First published | 2017-08-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Author | Tetsuya Mori |
| Maintainers | takyama, risacankidsstar, mkaya, hanage, fakestarbaby, monry |

## Links

- npm: https://www.npmjs.com/package/@umm/setting_core
- Repository: https://github.com/umm-projects/setting_core
- Issues: https://github.com/umm-projects/setting_core/issues
- npm.io page: https://npm.io/package/@umm/setting_core

## Dependencies (4)

- [ncp](https://npm.io/package/ncp.md) ^2.0.0
- [glob](https://npm.io/package/glob.md) ^7.1.2
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [rimraf](https://npm.io/package/rimraf.md) ^2.6.1

## Recent versions

- 1.1.0 (latest) — 2017-10-20
- 1.0.4 — 2017-09-11
- 1.0.2 — 2017-09-01
- 1.0.1 — 2017-08-17
- 1.0.0 — 2017-08-17

## README

# What?

* `***Setting.asset` 的な設定を管理するためのアセットの基底クラスです。

# Why?

* 結構な頻度で使うクラスなので、共通化して切り出したくなりました。

# Install

```shell
$ npm install github:umm-projects/setting_core.git
```

# Usage

```csharp
using UnityEngine;
using UnityModule.Settings;

class HogeSetting : Setting<HogeSetting> {

    public string Fuga;

#if UNITY_EDITOR

    [UnityEditor.MenuItem("Assets/Create/Setting/Create HogeSetting")]
    public static void CreateHogeSetting() {
        CreateAsset();
    }

#endif

}

class PiyoSetting : PrioritizeSetting<PiyoSetting> {

    public float Ponyo;

#if UNITY_EDITOR

    [UnityEditor.MenuItem("Assets/Create/Setting/Create PiyoSetting")]
    public static void CreatePiyoSetting() {
        CreateAsset();
    }

#endif


}

class Sample : MonoBehaviour {

    void Start() {
        Debug.Log(HogeSetting.Instance.Fuga);
        Debug.Log(PiyoSetting.Instance.Ponyo);
    }

}

```

* `Setting<T>` は基本的な設定クラスの基底クラスです。
  * `.Instance` という Singleton Getter を提供します。
* `PrioritizeSetting<T>` は `Setting<T>` の機能に加えて、プロジェクト内に複数の設定アセットがあった場合でも、優先度を付けて一元化出来るようにしたクラスです。
  * 現在の所、値の継承は実装しておりません。
* `Setting<T>.CreateAsset()` を呼ぶことで、空の `***Setting.asset` が `Assets/Resources/Settings/` 以下に生成されます。
  * メニューに表示させるために、 `UnityEditor.MenuItemAttribute` を用いると良いでしょう。
  * `#if UNITY_EDITOR ... #endif` で囲まないと実機ビルドした際にコンパイルエラーになります。

# License

Copyright (c) 2017 Tetsuya Mori

Released under the MIT license, see [LICENSE.txt](LICENSE.txt)

---
_Source: https://npm.io/package/@umm/setting_core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
