> For the complete documentation index, see [llms.txt](https://sinoa-dev.gitbook.io/rpgatsumaruapiforunity/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sinoa-dev.gitbook.io/rpgatsumaruapiforunity/sample-api/sample-code-list/initialize-api.md).

# 初期化をしよう

## 背景

PRGアツマールAPI for Unityを動かすためには必ず、プラグインの初期化をしなければなりません。他のあらゆる機能を使う前に必ず実行しましょう。

## 解説

RPGアツマールAPI for Unityは、プラグイン内部にコンテキストを持っているため このコンテキストを初期化しなければ、あらゆるAPIの動作は失敗してしまいます。

その、コンテキストを初期化するための手段が用意されています。

## サンプルコード

```csharp
using RpgAtsumaruApiForUnity;
using UnityEngine;

public class RpgAtsumaruSample : MonoBehaviour
{
    private void Awake()
    {
        // もしプラグインの初期化が終わっていないなら
        if (!RpgAtsumaruApi.Initialized)
        {
            // プラグインの初期化
            RpgAtsumaruApi.Initialize();
        }
    }
}
```
