Nifty Cloud Mobile Background and Unity.
Record the score using a unique ID.
If you have already scored, there is no problem.
Initial processing "If I didn't have that ID" doesn't work
Example
Taro 10 points
Hanako 8 points
I don't mind overwriting Taro here with 11 points, but
When I try to add Saburo 9 points, I get an error.
The action you want to add is to register a new ID with the ID if it does not already exist.
Or I would like to know the function "Search by ID and return whether or not it exists".
"Regarding the following code, the condition was ""no error"" for reference to the sample."
I think the problem is that the search results are not listed.
//<summary>
/// Record Score to NCMB Score (float) Game Name
/// </summary>
public static void saveScore(float score, string game) {
Debug.Log("score:"+score+", game:"+game);
string id = PlayerPrefs.GetString(RegisterID.UID, ""; // Call a unique ID
NCMBQuery<NCMBObject>query=newNCMBQuery<NCMBObject>(game);
query.WhereEqualTo("id", id); Search by //id
query.FindAsync ((List<NCMBObject>objList,NCMBExceptione) =>{
// If the search is successful
if(e==null){
Debug.Log("Search OK");
objList[0]["Score"]=score;
objList[0].SaveAsync();
} else {
// Debug.Log("saveScore:err") without spitting out the following log;
NCMBObject object j = new NCMBObject(game);
obj["id"] = PlayerPrefs.GetString(RegisterID.UID, "";
obj["Name"] = PlayerPrefs.GetString(RegisterID.NAME, ");
obj["Score"] = score;
obj.SaveAsync();
}
});
}
http://mb.cloud.nifty.com/doc/current/tutorial/unity_highscore.html
I haven't tried it yet, so I'm not sure if it's correct.
e==null
check the findAsync
results as far as the document above is concerned, and then
objList.Count==0
appears to confirm unregistered
© 2024 OneMinuteCode. All rights reserved.