Database 11之后无法向Firebase添加更多条目
我在firebase中有一个用于保存用户数据的数据库,我可以让它添加最多10个帐户数据(基于零),但在此之后,每当我调用函数添加到数据库时,它都不会显示在firebase中。我用这个来做一个团结的游戏。下面是函数调用Database 11之后无法向Firebase添加更多条目,database,firebase,unity3d,account,Database,Firebase,Unity3d,Account,我在firebase中有一个用于保存用户数据的数据库,我可以让它添加最多10个帐户数据(基于零),但在此之后,每当我调用函数添加到数据库时,它都不会显示在firebase中。我用这个来做一个团结的游戏。下面是函数调用 ` public void populateDatabase() { //populate static account data AccountData _thisAccount = new AccountData(); _thisAccount.acc
`
public void populateDatabase()
{
//populate static account data
AccountData _thisAccount = new AccountData();
_thisAccount.accName = Account.instance.NickName();
_thisAccount.accEmail = PlayerAccount._this.getUserEmail();
_thisAccount.accCash = 100;
_thisAccount.accGem = 100;
//Ranking Values
_thisAccount.Rank = 0;
//rookie
_thisAccount.RookieRank = 0;
_thisAccount.RookieAverage = 0;
_thisAccount.RookieScoreOne = 0;
_thisAccount.RookieScoreTwo = 0;
_thisAccount.RookieScoreThree = 0;
//Amature
_thisAccount.AmatureRank = 0;
_thisAccount.AmatureAverage = 0;
_thisAccount.AmatureScoreOne = 0;
_thisAccount.AmatureScoreTwo = 0;
_thisAccount.AmatureScoreThree = 0;
//Semi
_thisAccount.SemiProRank = 0;
_thisAccount.SemiAverage = 0;
_thisAccount.SemiProScoreOne = 0;
_thisAccount.SemiProScoreTwo = 0;
_thisAccount.SemiProScoreThree = 0;
//Pro
_thisAccount.ProRank = 0;
_thisAccount.ProAverage = 0;
_thisAccount.ProScoreOne = 0;
_thisAccount.ProScoreTwo = 0;
_thisAccount.ProScoreThree = 0;
_thisAccount.accTricks = Account.instance.ReturnTricks();
string tName = _thisAccount.getAccName();
Debug.Log("Name: " + tName + " account " + _thisAccount.accTricks.Length);
Debug.Log("Email: " + _thisAccount.accEmail);
Debug.Log("Cash: " + _thisAccount.accCash);
Debug.Log("Attempt to fill Database info");
ConstuctDatabase(usersdb, _thisAccount);
}
private void ConstuctDatabase(DatabaseReference AccountRef, AccountData _thisAccount)
{
int num = 0;
AccountRef.RunTransaction(MutableData =>
{
num++;
List<object> account = MutableData.Value as List<object>;
if (account == null)
{
account = new List<object>();
}
else
{
Debug.Log("continue");
}
Dictionary<string, object> newAccount =
new Dictionary<string, object>();
newAccount["AccountName"] = _thisAccount.accName;
newAccount["AccountEmail"] = _thisAccount.accEmail;
newAccount["Cash"] = _thisAccount.accCash;
newAccount["Gem"] = _thisAccount.accGem;
//Ranking Values
newAccount["Rank"] = _thisAccount.Rank;
//rookie
newAccount["RookieRank"] = _thisAccount.RookieRank;
newAccount["RookieAverage"] = _thisAccount.RookieAverage;
newAccount["RookieScoreOne"] = _thisAccount.RookieScoreOne;
newAccount["RookieScoreTwo"] = _thisAccount.RookieScoreTwo;
newAccount["RookieScoreThree"] = _thisAccount.RookieScoreThree;
//Amature
newAccount["AmateurRank"] = _thisAccount.AmatureRank;
newAccount["AmateurAverage"] = _thisAccount.AmatureAverage;
newAccount["AmateurScoreOne"] = _thisAccount.AmatureScoreOne;
newAccount["AmateurScoreTwo"] = _thisAccount.AmatureScoreTwo;
newAccount["AmateurScoreThree"] = _thisAccount.AmatureScoreThree;
//Semi
newAccount["SemiProRank"] = _thisAccount.SemiProRank;
newAccount["SemiProAverage"] = _thisAccount.SemiAverage;
newAccount["SemiProScoreOne"] = _thisAccount.SemiProScoreOne;
newAccount["SemiProScoreTwo"] = _thisAccount.SemiProScoreTwo;
newAccount["SemiProScoreThree"] = _thisAccount.SemiProScoreThree;
//Pro
newAccount["ProRank"] = _thisAccount.ProRank;
newAccount["ProAverage"] = _thisAccount.ProAverage;
newAccount["ProScoreOne"] = _thisAccount.ProScoreOne;
newAccount["ProScoreTwo"] = _thisAccount.ProScoreTwo;
newAccount["ProScoreThree"] = _thisAccount.ProScoreThree;
//Trick Logic]
Dictionary<string, bool> newTricks =
new Dictionary<string, bool>();
int i = 0;
while (i < _thisAccount.accTricks.Length)
{
newTricks["Trick" + i] = _thisAccount.accTricks[i]._owned;
i++;
}
newAccount["TrickList"] = newTricks;
Debug.Log("ConstructDB1");
account.Add(newAccount);
MutableData.Value = account;
Debug.Log("ConstructDB2");
return TransactionResult.Success(MutableData);
});
}
public void populatedDatabase()
{
//填充静态帐户数据
AccountData_thisAccount=新AccountData();
_thisAccount.accName=Account.instance.昵称();
_thisAccount.accEmail=PlayerAccount.\u this.getUserEmail();
_thisAccount.accCash=100;
_thisAccount.accGem=100;
//排名值
_此帐户。秩=0;
//新手
_thisAccount.RookieRank=0;
_thisAccount.RookieAverage=0;
_thisAccount.RookieScoreOne=0;
_thisAccount.RookieScoreTwo=0;
_thisAccount.RookieScoreThree=0;
//爱情
_thisAccount.AmatureRank=0;
_thisAccount.AmatureAverage=0;
_thisAccount.AmatureScoreOne=0;
_thisAccount.AmatureScore2=0;
_thisAccount.AmatureScoretree=0;
//半
_thisAccount.SemiProRank=0;
_该账户的半平均值=0;
_thisAccount.SemiProScoreOne=0;
_thisAccount.SemiProScoreTwo=0;
_thisAccount.SemiProsCoreTree=0;
//专业的
_thisAccount.ProRank=0;
_thisAccount.ProAverage=0;
_thiscomport.ProScoreOne=0;
_thiscomport.ProScoreTwo=0;
_thisAccount.ProsCoreTree=0;
_thisAccount.accTricks=Account.instance.ReturnTricks();
字符串tName=_thisAccount.getAccName();
Log(“名称:“+tName+”帐户“+_thisAccount.accctricks.Length”);
Log(“电子邮件:”+_thisAccount.accmail);
Log(“现金:”+_thisAccount.accCash);
Log(“尝试填充数据库信息”);
构造数据库(usersdb,_thisAccount);
}
私有void constructDatabase(DatabaseReference AccountRef,AccountData\u thisAccount)
{
int num=0;
AccountRef.RunTransaction(可变数据=>
{
num++;
列表科目=可变数据。值为列表;
如果(帐户==null)
{
帐户=新列表();
}
其他的
{
Debug.Log(“继续”);
}
字典新帐户=
新字典();
newAccount[“AccountName”]=\u thisAccount.accName;
newAccount[“AccountEmail”]=\u thisAccount.accEmail;
新帐户[“现金”]=\u thisAccount.accCash;
newAccount[“Gem”]=\u thisAccount.accGem;
//排名值
newAccount[“Rank”]=此Account.Rank;
//新手
newAccount[“RookieRank”]=\u thisAccount.RookieRank;
newAccount[“RookeeAverage”]=\u thisAccount.RookeeAverage;
newAccount[“RookeeScoreOne”]=\u thisAccount.RookeeScoreOne;
newAccount[“RookeeScoreTwo”]=\u thisAccount.RookeeScoreTwo;
newAccount[“RookeeScoreThree”]=\u thiscoount.rookeeScoreThree;
//爱情
newAccount[“业余银行”]=\u thisAccount.AmatureRank;
newAccount[“业余旅行”]=\u thisAccount.AmatureAverage;
newAccount[“业余核心用户”]=\u thisAccount.AmatureScoreOne;
newAccount[“业余者得分二”]=\u thisAccount.AmatureScoreTwo;
newAccount[“业余者得分三”]=\u thiscoount.amaturescoretree;
//半
newAccount[“SemiProRank”]=此Account.SemiProRank;
newAccount[“半预平均”]=此Account.SemiAverage;
新帐户[“SemiProScoreOne”]=\u thisAccount.SemiProScoreOne;
newAccount[“SemiProsCoreTower”]=\u thisAccount.SemiProsCoreTower;
newAccount[“SemiProsCoreTree”]=此Account.SemiProsCoreTree;
//专业的
newAccount[“ProRank”]=\u thisAccount.ProRank;
newAccount[“ProAverage”]=此Account.ProAverage;
newAccount[“ProScoreOne”]=\u thisAccount.ProScoreOne;
新帐户[“ProScoreTwo”]=\u thisAccount.ProScoreTwo;
newAccount[“ProsCoreTree”]=\u thisAccount.ProsCoreTree;
//技巧逻辑]
纽特里克斯词典=
新字典();
int i=0;
while(i<\u this account.accctricks.Length)
{
newTricks[“Trick”+i]=\u this account.accTricks[i]。\u拥有;
i++;
}
newAccount[“TrickList”]=newTricks;
Log(“ConstructDB1”);
账户。添加(新账户);
可变数据。值=帐户;
Log(“ConstructDB2”);
返回TransactionResult.Success(可变数据);
});
}
`不幸的是,这是6.6.0中的一个已知问题。如果你注意到这个问题,我建议你尽快升级
public void populateDatabase()
{
//populate static account data
AccountData _thisAccount = new AccountData();
_thisAccount.accName = Account.instance.NickName();
_thisAccount.accEmail = PlayerAccount._this.getUserEmail();
_thisAccount.accCash = 100;
_thisAccount.accGem = 100;
//Ranking Values
_thisAccount.Rank = 0;
//rookie
_thisAccount.RookieRank = 0;
_thisAccount.RookieAverage = 0;
_thisAccount.RookieScoreOne = 0;
_thisAccount.RookieScoreTwo = 0;
_thisAccount.RookieScoreThree = 0;
//Amature
_thisAccount.AmatureRank = 0;
_thisAccount.AmatureAverage = 0;
_thisAccount.AmatureScoreOne = 0;
_thisAccount.AmatureScoreTwo = 0;
_thisAccount.AmatureScoreThree = 0;
//Semi
_thisAccount.SemiProRank = 0;
_thisAccount.SemiAverage = 0;
_thisAccount.SemiProScoreOne = 0;
_thisAccount.SemiProScoreTwo = 0;
_thisAccount.SemiProScoreThree = 0;
//Pro
_thisAccount.ProRank = 0;
_thisAccount.ProAverage = 0;
_thisAccount.ProScoreOne = 0;
_thisAccount.ProScoreTwo = 0;
_thisAccount.ProScoreThree = 0;
_thisAccount.accTricks = Account.instance.ReturnTricks();
string tName = _thisAccount.getAccName();
Debug.Log("Name: " + tName + " account " + _thisAccount.accTricks.Length);
Debug.Log("Email: " + _thisAccount.accEmail);
Debug.Log("Cash: " + _thisAccount.accCash);
Debug.Log("Attempt to fill Database info");
ConstuctDatabase(usersdb, _thisAccount);
}
private void ConstuctDatabase(DatabaseReference AccountRef, AccountData _thisAccount)
{
int num = 0;
AccountRef.RunTransaction(MutableData =>
{
num++;
List<object> account = MutableData.Value as List<object>;
if (account == null)
{
account = new List<object>();
}
else
{
Debug.Log("continue");
}
Dictionary<string, object> newAccount =
new Dictionary<string, object>();
newAccount["AccountName"] = _thisAccount.accName;
newAccount["AccountEmail"] = _thisAccount.accEmail;
newAccount["Cash"] = _thisAccount.accCash;
newAccount["Gem"] = _thisAccount.accGem;
//Ranking Values
newAccount["Rank"] = _thisAccount.Rank;
//rookie
newAccount["RookieRank"] = _thisAccount.RookieRank;
newAccount["RookieAverage"] = _thisAccount.RookieAverage;
newAccount["RookieScoreOne"] = _thisAccount.RookieScoreOne;
newAccount["RookieScoreTwo"] = _thisAccount.RookieScoreTwo;
newAccount["RookieScoreThree"] = _thisAccount.RookieScoreThree;
//Amature
newAccount["AmateurRank"] = _thisAccount.AmatureRank;
newAccount["AmateurAverage"] = _thisAccount.AmatureAverage;
newAccount["AmateurScoreOne"] = _thisAccount.AmatureScoreOne;
newAccount["AmateurScoreTwo"] = _thisAccount.AmatureScoreTwo;
newAccount["AmateurScoreThree"] = _thisAccount.AmatureScoreThree;
//Semi
newAccount["SemiProRank"] = _thisAccount.SemiProRank;
newAccount["SemiProAverage"] = _thisAccount.SemiAverage;
newAccount["SemiProScoreOne"] = _thisAccount.SemiProScoreOne;
newAccount["SemiProScoreTwo"] = _thisAccount.SemiProScoreTwo;
newAccount["SemiProScoreThree"] = _thisAccount.SemiProScoreThree;
//Pro
newAccount["ProRank"] = _thisAccount.ProRank;
newAccount["ProAverage"] = _thisAccount.ProAverage;
newAccount["ProScoreOne"] = _thisAccount.ProScoreOne;
newAccount["ProScoreTwo"] = _thisAccount.ProScoreTwo;
newAccount["ProScoreThree"] = _thisAccount.ProScoreThree;
//Trick Logic]
Dictionary<string, bool> newTricks =
new Dictionary<string, bool>();
int i = 0;
while (i < _thisAccount.accTricks.Length)
{
newTricks["Trick" + i] = _thisAccount.accTricks[i]._owned;
i++;
}
newAccount["TrickList"] = newTricks;
Debug.Log("ConstructDB1");
account.Add(newAccount);
MutableData.Value = account;
Debug.Log("ConstructDB2");
return TransactionResult.Success(MutableData);
});
}
现在,我们来解释一下一个小的解决方法:数组被序列化为一个带有数字键的字典。它按字典顺序解析数字(例如:它在做一些事情,比如1,10,2,3,4,5,6…),它在11处中断。要解决此问题,请尝试使用按字典顺序排列的键(例如:M001、M002、M003和c)序列化字典,而不是像当前那样添加列表。我知道这并不理想,但它应该暂时解除你的阻碍