Skip to content

Instantly share code, notes, and snippets.

@peroon
Last active August 29, 2015 14:24
Show Gist options
  • Save peroon/16edb2135f152d6eb4b9 to your computer and use it in GitHub Desktop.
Save peroon/16edb2135f152d6eb4b9 to your computer and use it in GitHub Desktop.
Parse.com + Unityサンプル
// AssetStore's parse asset doesn't work.
// SDK page sample project works.
using UnityEngine;
using System.Collections;
using Parse;
public class ParseTest : MonoBehaviour {
public void OnClickSend(){
ParseObject testObject = new ParseObject("Enemy");
testObject["attack"] = 123;
testObject["name"] = "name";
testObject.SaveAsync();
}
public void OnClickGet(){
//StartCoroutine (this.GetCoroutine ());
StartCoroutine (this.RankingCoroutine());
}
// Get All
IEnumerator GetCoroutine(){
ParseQuery<ParseObject> query = ParseObject.GetQuery("Enemy");
var result = query.FindAsync ();
while (!result.IsCompleted) {
yield return null;
}
foreach (var parseObject in result.Result) {
Debug.Log(parseObject["name"]);
Debug.Log(parseObject["attack"]);
}
}
// Get limited ranking
IEnumerator RankingCoroutine(){
ParseQuery<ParseObject> query = ParseObject.GetQuery("Enemy").OrderByDescending("attack").Limit(2);
var result = query.FindAsync ();
while (!result.IsCompleted) {
yield return null;
}
foreach (var parseObject in result.Result) {
Debug.Log(parseObject["name"]);
Debug.Log(parseObject["attack"]);
}
}
}
@peroon
Copy link
Author

peroon commented Jul 1, 2015

攻撃力順に上位X件を取得、のようなランキング用クエリを追加

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment