UnityでFirebase RealTimeDatabaseを使ってアプリを作っています。
Firebaseコンソールでは
1)プロジェクトを作成
2)アプリを登録
3)RealTimeDatabaseを作成(とりあえずルールはなしで設定)
4)取得したgoogleService-info.plistとgoogle-services.jsonをAssets下に設置
5)RealTimeDatabase Packageをインポート
しました。
そこで下記のコードを書いてシュミレータでテストしたのですが
Unityのロゴがついたダイアログが出て何かインストールしているようになって
そのあとエラーになってクラッシュします。
エラーメッセージは
Could not initialize persistence.Unable to find app data directory.
です。
アプリがないというエラーなのでFirebaseコンソールに登録したIDと
Unityで登録しているIDが間違っているかと思いましたがそれは合っています。
またFirebaseAuthは問題なく認証されています。
とういった原因が考えられるでしょうか?わかる方お教え下さい。
PC: Windows10
Unity2019.4.0f1
言語:C#
FirebaseDbScript.cs
using System.Collections; using System.Collections.Generic; using UnityEngine; using System; using System.Linq; using Firebase; using Firebase.Database; using Firebase.Unity.Editor; using UnityEngine.UI; using UnityEngine.SceneManagement; public class FirebaseDbScript : MonoBehaviour { int firstFlag; Firebase.Auth.FirebaseUser _FirebaseUser; //Firebaseに接続した際の認証情報を保持する。 string inputPlace; string inputPosition; string PrefName; string PrefAddress; string PrefPosition; int PrefNum; int MonthTotal; int SetMonth; int defaultMonth; int suburiTotal; int suburiMonthTotal; void Start(){ //日付取得 DateTime now = DateTime.Now; int nowYear = now.Year; int nowMonth = now.Month; defaultMonth = (int)Mathf.Floor(nowYear * 100 + nowMonth); Firebase.Auth.FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance; auth.SignInAnonymouslyAsync().ContinueWith(task => { if(task.IsCanceled){ Debug.LogError("SignInAnonymouslyAsync was canceled."); return; } if(task.IsFaulted){ Debug.LogError("SignInAnonymouslyAsync encountered an error:" + task.Exception); return; } _FirebaseUser = task.Result; Debug.LogFormat("User signed in succesfully: {0} ({1})", _FirebaseUser.DisplayName, _FirebaseUser.UserId); }); //Firebaseへの接続 FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://hogehoge.firebaseio.com/"); DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference; } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。