Last active
August 29, 2015 14:24
-
-
Save peroon/16edb2135f152d6eb4b9 to your computer and use it in GitHub Desktop.
Parse.com + Unityサンプル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
攻撃力順に上位X件を取得、のようなランキング用クエリを追加