早上好
因此,我能够在某种程度上从我的firebase文档和集合中加载信息......
当我的馆藏有1个文件时,一切顺利。 当它有超过1个文档时,应用程序会中断。
所以,我有这个:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Gaze_Timer : MonoBehaviour {
public int gazeTime = 3; //the amount of time needed to look to teleport
public GameObject playerCam; //the players camera
private Vector3 startingPosition;
private Vector3 changePosition;
private bool startCoRoutine; //is the co-routine running
void Start() {
startingPosition = transform.localPosition;
changePosition = startingPosition;
startCoRoutine = false; //testing this out as true or false
}
void Update() {
//...
}
// when I gaze
public void PointerEnter() {
Debug.Log("I entered.");
if (startCoRoutine) {
StopCoroutine("waypointTimerEvent");
} else {
StartCoroutine("waypointTimerEvent", gazeTime);
}
startCoRoutine = !startCoRoutine;
}
// when I look away
public void PointerExit() {
Debug.Log("I exited.");
if (startCoRoutine) {
StopCoroutine("waypointTimerEvent");
startCoRoutine = false;
}
}
IEnumerator waypointTimerEvent(float waitTime) {
yield return new WaitForSeconds(waitTime);
Debug.Log("I waited " + waitTime + " seconds");
GetComponent<Renderer>().material.color = Color.blue;
changePosition.y += 0.1f;
transform.localPosition = changePosition;
}
}
对于此Firestore设置:https://imgur.com/a/pmBcE
然后我收到此错误:db.collection("KitListCategorie").get().addOnSuccessListener { snapshot ->
for (document1 in snapshot.documents) {
val data1 = document1.data
val weights = data1["categoryName"] as String
val misc = data1["categoryName"] as String
categorySpinnerArray.add(weights)
categorySpinnerArray.add(misc)
}
categorySpinnerArrayAdapter.notifyDataSetChanged()
}
我做错了什么?
由于
答案 0 :(得分:1)
你犯了一个简单的错误。在Firebase中的屏幕截图中,您可以使用#34; categoryName&#34;标题为&#34; categoryname&#34;所以它返回null并且kotlin抛出异常。