{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/ja/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"type":"markdown"},"seo":{"title":"Unity SDK For PC","description":"Unity SDKを使用してTreasure AIにデータを送信する方法を解説。PC向けUnityアプリでのデータ追跡とGDPRコンプライアンスについて詳しく説明します。","siteUrl":"https://docs.treasure.ai","lang":"en-US","jsonLd":{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.treasure.ai/","name":"Treasure AI","url":"https://www.treasure.ai/","logo":"https://www.treasure.ai/hubfs/assets/images/logos/primary-logo.svg"},{"@type":"WebSite","@id":"https://docs.treasure.ai/#website","name":"Treasure AI Documentation","url":"https://docs.treasure.ai/","inLanguage":["en","ja"],"publisher":{"@id":"https://www.treasure.ai/"}}]},"llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"unity-sdk-for-pc","__idx":0},"children":["Unity SDK For PC"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://unity3d.com/"},"children":["Unity"]},"アプリからTreasure Dataにデータを送信するには、Unity SDKライブラリを使用します。SDKを使用することで、Webサイトのアクティビティを追跡するためにサーバー側に何もインストールする必要がありません。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"gdprコンプライアンス","__idx":1},"children":["GDPRコンプライアンス"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["欧州一般データ保護規則などの国内およびグローバルなデータプライバシー要件への準拠をサポートするため、当社のSDKは、アプリケーションやWebサイトにおける個人データおよびメタデータの収集と追跡を制御するメソッドを提供しています。企業が個人データに関するデータプライバシーポリシーを定義する際、これらのメソッドをコード内で使用して、デフォルトのデータ収集動作を実装し、個人がデータ収集とプライバシーを自分で管理するためのコントロールを追加できます。"]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"warning"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Dataのお客様は、個人データを収集する使用を含むSDKの使用が、Treasure Dataサービスへのアクセスと使用を管理する法的契約、特に",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.treasuredata.com/terms/"},"children":["Treasure Dataの現行利用規約"]},"、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.treasuredata.com/privacy/"},"children":["プライバシーポリシー"]},"、および",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.treasuredata.com/td-downloads/Privacy-Statement-for-Customer-Data.pdf"},"children":["顧客データのプライバシーステートメント"]},"に準拠していることを確認する必要があります。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"前提条件","__idx":2},"children":["前提条件"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Unity開発の基礎知識"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Treasure Dataの基礎知識"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"ライブラリのインストール","__idx":3},"children":["ライブラリのインストール"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["最新バージョンの",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/td-unity-sdk-package"},"children":["Unity package"]},"をダウンロードし、Assets > Import Package > Custom Packageを使用してUnityプロジェクトにインポートします。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"pc-modeの有効化","__idx":4},"children":["PC Modeの有効化"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Player Settings > Scripting Define SymbolsにシンボルTD_SDK_DEV_MODEを追加します。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"ライブラリの初期化","__idx":5},"children":["ライブラリの初期化"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["次に、アプリ内で以下のようにライブラリを初期化します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"csharp","header":{"controls":{"copy":{}}},"source":"public class MyTreasureDataPlugin : MonoBehaviour {\n  private TreasureData td = null;\n\n  void Start() {\n    TreasureData.InitializeApiEndpoint(\"https://in.treasuredata.com\");\n    td = new TreasureData(\"YOUR_API_KEY\");\n    ...\n    // If you want to use a TDClient over scenes, pass `true` to\n    // `SimpleTDClient.Create` to prevent it from being removed.\n    // Otherwise, pass 'false' If you want to use a TDClient only\n    // within a scene, don't pass `true` to `SimpleTDClient.Create`\n    // so that you can prevent object leaks.\n    td.SetSimpleTDClient(SimpleTDClient.Create(true));\n  }\n\n  void OnApplicationPause(bool pauseStatus) {\n    // Make an open request whenever app is resumed\n    if (!pauseStatus) {\n      td.UploadEvents(\n        delegate() { Debug.LogWarning (\"UploadEvents Success!!! \"); },\n        delegate(string errorCode, string errorMsg) { Debug.LogWarning (\"UploadEvents Error!!! errorCode=\" + errorCode + \", errorMsg=\" + errorMsg); }\n      );\n    }\n  }\n\n  void OnApplicationQuit()\n  {\n    // Make an open request when app is quitting\n    td.UploadEvents(\n      delegate() { Debug.LogWarning (\"UploadEvents Success!!! \"); },\n      delegate(string errorCode, string errorMsg) { Debug.LogWarning (\"UploadEvents Error!!! errorCode=\" + errorCode + \", errorMsg=\" + errorMsg); }\n    );\n  }\n}\n","lang":"csharp"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["APIキーはTD ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://console.treasuredata.com/app/users/current"},"children":["Console"]},"から取得できます。SDKには",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.treasuredata.com/smart/project-product-documentation/about-access-control"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["書き込み専用APIキー"]}]},"を使用することを推奨します。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["バッファされたイベントをいつ、どのくらいの頻度でアップロードするかは、アプリケーションの特性によって異なります。アップロードに適したタイミングには以下が含まれます。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["現在の画面が閉じられる時、またはバックグラウンドに移動する時"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["アプリケーションを閉じる時"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"個人情報の追跡を有効化オプション","__idx":6},"children":["個人情報の追跡を有効化(オプション)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["さまざまなドメインにおけるデータプライバシー規制、特にEUのGDPRに準拠するため、Treasure Data Unity SDKはデフォルトでは個人を特定できる特定のイベントメタデータを収集しません。具体的には、以下の情報はデフォルトでは収集されません。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["td_uuid - クライアントの識別子、このデバイス上のこのアプリケーションのこのインストールに固有"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["td_uuidは、個々のユーザーを追跡し、ユーザーセッション内および複数セッションにわたってデータを分析し、追跡された行動を実在の個人に関連付ける場合などに必要です。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["収集すべき個人情報について、会社のデータプライバシー責任者および法務顧問とデータ収集ポリシーを確認する必要があります。個人の追跡を有効にすることを決定した場合は、同意管理システムと統合して、個々のユーザーの追跡へのオプトインを追跡することも推奨します。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ユーザーの同意を確認したら、個人データの収集を有効にできます。例:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"td.EnableAutoAppendUniqId();\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["テストでは、収集している情報を確認し、意図した個人情報のみが含まれ、それ以上のものが含まれていないことを確認してください。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"cloudへのイベント送信","__idx":7},"children":["Cloudへのイベント送信"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["次に、アプリケーション内の適切なタイミングでAddEvent()関数を呼び出します。以下の例は、database_a内のtable_bテーブルにイベントが送信されることを示しています。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"Dictionary<string, object> ev = new Dictionary<string, object>();\nev[\"str\"] = \"strstr\";\nev[\"int\"] = 12345;\nev[\"long\"] = 12345678912345678;\nev[\"float\"] = 12.345;\nev[\"double\"] = 12.3459832987654;\nev[\"bool\"] = true;\ntd.AddEvent(\"database_a\", \"table_b\", ev);\n"},"children":[]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"warning"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["IPホワイトリストは、Unity SDKからのインポートには適用されません。また、ブラウザは頻繁に無効なタイムスタンプ(1970/01/01など)を指定することが確認されているため、現在、7日前より古く、3日以上先のタイムスタンプを持つレコードは無視されます。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"その他の機能とオプション","__idx":8},"children":["その他の機能とオプション"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"アプリケーションライフサイクルイベントの追跡","__idx":9},"children":["アプリケーションライフサイクルイベントの追跡"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["オプションとして、このSDKはアプリライフサイクルイベントを自動的にキャプチャするように有効にできます(デフォルトでは無効)。このオプションを明示的に有効にする必要があります。",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["setDefaultTable()"]},"を通じてターゲットテーブルを設定できます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"csharp","header":{"controls":{"copy":{}}},"source":"[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]\nstatic void OnRuntimeInitialization() {\n  // TreasureData client setup...\n  TreasureData.DefaultTable = \"app_lifecycles\";\n  TreasureData.Instance.EnableAppLifecycleEvent();\n}\n","lang":"csharp"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["自動的に追跡される3種類のイベントがあります。Application Open、Install、Updateです。これらのイベントは、イベントの特定のタイプに応じた関連メタデータとともにキャプチャされます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Application Open"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":" {\n     \"tdunityevent\": \"TDUNITYAPPOPEN\",\n     \"tdapp_ver\": \"1.0\",\n     ...\n }\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Application Install"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\n  \"tdunityevent\": \"TDUNITYAPPINSTALL\",\n  \"tdapp_ver\": \"1.0\",\n  ...\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Application Update"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"    {\n        \"tdunityevent\": \"TDUNITYAPPUPDATE\",\n        \"tdappver\": \"1.1\",\n        \"tdapppreviousver\": \"1.0\",\n        ...\n    }\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"オプトアウト","__idx":10},"children":["オプトアウト"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["このSDKは、特定のデバイスのすべてのイベント追跡をオプトアウトし、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_uuid"]},"をリセット(または完全に無効化)することでユーザーを非識別化できます。後続のすべてのイベントに対して",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_uuid"]},"を別のIDに変更できます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"csharp","header":{"controls":{"copy":{}}},"source":"TreasureData.Instance.disableCustomEvent();        // disable your own events, ones that collect through manual calls to addEvent...\nTreasureData.Instance.disableAppLifecycleEvent();  // disable the auto-collected app lifecycle events\n","lang":"csharp"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["他のオプションフラグとは異なり、enable/disableCustomEventとenable/disableAppLifecycleEventは永続的な設定であり、これらの設定はアプリの起動を跨いで保持されます。ユーザーが追跡されたくないことを示した場合は、この呼び出しを使用することが重要です。Treasure Dataクライアントのセットアップごとにオプションを呼び出す必要はありません。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"csharp","header":{"controls":{"copy":{}}},"source":"TreasureData.Instance.resetUniqId();\nTreasureData.Instance.disableAppendUniqId();  // temporary configuration, need to call on Treasure Data client setup\n","lang":"csharp"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["オプションフラグ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["resetUniqId"]},"は、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DefaultTable"]},"に監査イベントも追加します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"csharp","header":{"controls":{"copy":{}}},"source":"    {\n        \"td_unity_event\": \"forget_device_uuid\",\n        \"td_uuid\": ,\n\n    }\n","lang":"csharp"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"アップロードの再試行と重複排除","__idx":11},"children":["アップロードの再試行と重複排除"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["モバイルまたはUnity SDKのデータ転送中の重複レコードを回避するため、Treasure Dataはレコードごとの重複排除を提供しています。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["レコードごとの重複排除は、顧客がレコード内で提供したUUIDフィールド(またはメタデータとして提供される内部割り当てUUID)に基づいています。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["SDKは、これらの機能の組み合わせにより1つのスタイルでイベントをインポートします。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["このSDKは、一意のキーを追加してバッファされたイベントを保持し、イベントがサーバー側にアップロードおよび保存されたことを確認するまでアップロードを再試行します(少なくとも1回)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["サーバー側は、デフォルトで過去1時間以内のすべてのイベントの一意のキーを記憶し、重複インポートを防ぐことができます"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["重複排除は、同じデータセット内で同じ識別子を持つレコードが最大で過去1時間以内、または過去4096レコード以内(いずれか早い方)に見られた場合に重複レコードを識別するベストエフォートシステムです。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"次のステップ","__idx":12},"children":["次のステップ"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Unity SDKはGitHubで入手できます。最新のSDKを使用していることを確認するため、リポジトリをチェックしてください。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/td-unity-sdk-package"},"children":["https://github.com/treasure-data/td-unity-sdk-package"]}]}]}]},"headings":[{"value":"Unity SDK For PC","id":"unity-sdk-for-pc","depth":1},{"value":"GDPRコンプライアンス","id":"gdprコンプライアンス","depth":2},{"value":"前提条件","id":"前提条件","depth":2},{"value":"ライブラリのインストール","id":"ライブラリのインストール","depth":2},{"value":"PC Modeの有効化","id":"pc-modeの有効化","depth":2},{"value":"ライブラリの初期化","id":"ライブラリの初期化","depth":1},{"value":"個人情報の追跡を有効化(オプション)","id":"個人情報の追跡を有効化オプション","depth":2},{"value":"Cloudへのイベント送信","id":"cloudへのイベント送信","depth":2},{"value":"その他の機能とオプション","id":"その他の機能とオプション","depth":2},{"value":"アプリケーションライフサイクルイベントの追跡","id":"アプリケーションライフサイクルイベントの追跡","depth":3},{"value":"オプトアウト","id":"オプトアウト","depth":2},{"value":"アップロードの再試行と重複排除","id":"アップロードの再試行と重複排除","depth":2},{"value":"次のステップ","id":"次のステップ","depth":2}],"frontmatter":{"seo":{"title":"Unity SDK For PC","description":"Unity SDKを使用してTreasure AIにデータを送信する方法を解説。PC向けUnityアプリでのデータ追跡とGDPRコンプライアンスについて詳しく説明します。"}},"lastModified":"2026-06-17T07:22:53.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/ja/int/unity-sdk-for-pc","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}