# URLに添えられたパラメータを取り出そう

## 背景

外部サイトから、パラメータ付きのリンクを開くことにより、どこからゲームを起動されたのか専用のユーザーコードによる起動で、特別なアイテムを付与したりといった事などが出来ます。

## 解説

ゲームURLにクエリとして「param1=～\&param2=～」といった変数を付けて、ゲームを起動された際に このパラメータをゲーム側で取り出すために、クエリ変数取得機能を使います。 RPGアツマールの仕様上、扱えるクエリ変数は"param"から始まる"1～9"までの変数となっております。

## サンプルコード

```csharp
using RpgAtsumaruApiForUnity;
using UnityEngine;

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


    private void Start()
    {
        // もし param1 に特別なコードが設定されていたら
        if (RpgAtsumaruApi.GeneralApi.GetQuery("param1") == "specialcode")
        {
            // 無敵モードになる処理を入れたり、アイテムプレゼント処理を入れたり、してみると良いかもです。
        }
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sinoa-dev.gitbook.io/rpgatsumaruapiforunity/sample-api/sample-code-list/get-url-query-parameters.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
