やったこと
・サーバー日時の取得・取得にかかる時間の計測
サーバー日時の取得
ここ見ながらプロジェクト作成
https://parse.com/apps/quickstartこんな感じのスクリプトを書いた。
using Parse;
using UnityEngine;
public class testParse : MonoBehaviour
{
void Start ()
{
ParseObject o = new ParseObject ("EVENT");
o.SaveAsync ().ContinueWith (t => {
Debug.Log ("TIMESTAMP " + o.UpdatedAt);
});
}
}
ParseObjectを更新するとUpdatedAtってプロパティに時間が入るようなのでそれを取ればいいみたい。
実行
問題なく取れた。
標準時っぽいね。
取得にかかる時間
スクリプトを変更
using Parse;
using UnityEngine;
using System.Collections;
public class testParse : MonoBehaviour
{
private Queue msgQueue = new Queue ();
void Start ()
{
msgQueue.Enqueue ("Start");
ParseObject o = new ParseObject ("EVENT");
o.SaveAsync ().ContinueWith (t => {
msgQueue.Enqueue ("Saved Async Complete");
msgQueue.Enqueue ("TIMESTAMP " + o.UpdatedAt);
});
msgQueue.Enqueue ("End");
}
void Update ()
{
if (msgQueue.Count > 0) {
string msg = string.Format ("{0} {1}", Time.time, msgQueue.Dequeue ());
Debug.Log (msg);
}
}
}
・別スレッドからTime.time呼べなかったからQueue使った。・task.Wait()でいいと思うんだけど使うとなんかフリーズした。
実行
1秒ちょい。こんなもんか。おまけ iPhoneでも計測
これも1秒ちょい。時間はそんな変わんなかった。非同期で使えばそんなに気にならない時間なのかな〜。



