Version: 2017.1
导入 SDK
附加游戏脚本

创建游戏脚本

通过创建脚本启动玩家会话

在 Unity Editor 中,通过转至 Assets > Create > C# Script 来新建 C# 脚本 将新建脚本命名为:__UnityAnalyticsIntegration__(命名必须准确才能使脚本正常运行)

打开脚本并复制代码

Double-click on the script to open your script in MonoDevelop. Completely replace the default generated code with the code below and click “Save” in MonoDevelop. The Unity Project ID that you see in the sample code below is unique to your game. It is used to link your Editor project to your Analytics dashboard.

转至 Analytics Dashboard 查看唯一的功能性项目 ID

using UnityEngine;
using System.Collections;
using UnityEngine.Cloud.Analytics;

public class UnityAnalyticsIntegration : MonoBehaviour {

    // 此函数用于初始化
    void Start () {

        const string projectId = "SAMPLE-UNITY-PROJECT-ID";
        UnityAnalytics.StartSDK (projectId);

    }

}
导入 SDK
附加游戏脚本