??????????????Щ??????
????const int recordsPerPage = 5;
????const string URL = "127.0.0.1:5000/scores";
??????????????????
????public struct Data {
????public int id;
????public string name;
????public int score;
????}
?????????????????????????????WWW???LitJson??WWW????Unity????????HTTP???????LitJson?????C#????JSON??????????LitJson????????????dll??????????Asset??
????SaveLoad?????????????????????????Save??????Load??
public void Save(Data data)
{
var jsonString = JsonMapper.ToJson(data);
var headers = new Dictionary<string?? string> ();
headers.Add ("Content-Type"?? "application/json");
var scores = new WWW (URL?? new System.Text.UTF8Encoding ().GetBytes (jsonString)?? headers);
StartCoroutine (WaitForPost (scores));
}
IEnumerator WaitForPost(WWW www){
yield return www;
Debug.Log (www.text);
}
??????????WWW??????????URL??header?????????????е?JsonMapper??????????JSON????????????????????е??????JSON?е???????????
public void Load()
{
var scores = new WWW (URL);
StartCoroutine(WaitForGet(scores));
}
IEnumerator WaitForGet(WWW www){
yield return www;
if (www.error == null && www.isDone) {
var dataList = JsonMapper.ToObject<DataList>(www.text);
data = dataList.data;
}else{
Debug.Log ("Failed to connect to server!");
Debug.Log (www.error);
}
}
????Load????????????index?????????JSON????????????????????????????????DataList?????е???????List<Data>??
????????????????????????????????????????????????UI?????????????д?????????????????С?????????????GitHub??????
????????????????顣????????SAE?м???????
??????????????????????????MySQLdb??
????????????????????unicode????????????????????????????
????# -*- coding:utf8 -*-
????#encoding = utf-8
?????????????Unity????????????????????????curl?????????????????Unity??????
????SecurityException: No valid crossdomain policy available to allow access
????????????????????????????????????????crossdomain.xml??????????????????£?
????<?xml version="1.0"?>
????<!DOCTYPE cross-domain-policy SYSTEM
????"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
????<cross-domain-policy>
????<site-control permitted-cross-domain-policies="master-only"/>
????<allow-access-from domain="*"/>
????<allow-http-request-headers-from domain="*" headers="*"/>
????</cross-domain-policy>
????????SAE??????????????????????????Flask??e??????
????@app.route('/crossdomain.xml')
????def fake():
????xml = """????????????"""
????return xml?? 200?? {'Content-Type': 'text/xml; charset=ascii'}