반응형
파이어베이스 SDK 다운로드
압축 푼 뒤
dotnet4 / FirebaseAnalytics.unitypackage 설치
- 코드 작성
using Firebase;
using Firebase.Analytics;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FirebaseManager : MonoBehaviour
{
FirebaseApp app;
void Start()
{
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
var dependencyStatus = task.Result;
if (dependencyStatus == Firebase.DependencyStatus.Available)
{
app = Firebase.FirebaseApp.DefaultInstance;
Debug.Log("파이어베이스 앱 초기화 완료");
}
else
{
UnityEngine.Debug.LogError(System.String.Format(
"Could not resolve all Firebase dependencies: {0}", dependencyStatus));
}
});
}
}
- 다른 코드에서 이벤트 설정
using Firebase.Analytics;
public class Example : MonoBehaviour
{
public int gold = 5;
public int crystal = 10;
void Awake()
{
FirebaseAnalytics.LogEvent("Login");
}
public void OnClick()
{
FirebaseAnalytics.LogEvent("Money","Gold", gold);
FirebaseAnalytics.LogEvent("Money","Crystal", crystal);
}
}
반응형