Skip to content

Instantly share code, notes, and snippets.

@kazumalab
Created October 31, 2016 09:01
Show Gist options
  • Save kazumalab/f64defbaae669c87adcc4439ab082f9e to your computer and use it in GitHub Desktop.
Save kazumalab/f64defbaae669c87adcc4439ab082f9e to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using SimpleFirebaseUnity;
using System.Collections.Generic;
public class NetworkTest : MonoBehaviour {
public InputField input;
private List<string> messageList = new List<string>();
public void AddText () { // Add to List
if (input.text != "") {
print ("Add message : " + input.text);
messageList.Add (input.text);
}
}
public void PushMessage () { // Send to Firebase.
Firebase firebase = NetworkSingleton.Instance.firebase;
NetworkSingleton.Instance.firebaseQueue.AddQueueUpdate (firebase, SetJson(messageList), FirebaseParam.Empty.PrintPretty ());
}
private Dictionary<string, object> SetJson(List<string> mlist) {
// データの形は使う形に合わせて書く?もっと良い書き方ある?かも
Dictionary<string, object> Dashboard = new Dictionary<string, object> ();
Dictionary<string, object> list = new Dictionary<string, object> ();
Dictionary<string, object> place = new Dictionary<string, object> ();
int i = 0;
foreach (var ms in mlist) {
Dictionary<string, object> Data = new Dictionary<string, object> ();
Data.Add ("name", "kauzma");
Data.Add ("text", ms);
print (ms);
list.Add ("m" + i, Data);
i++;
}
Dashboard.Add ("message", list);
return Dashboard;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment