Example #1
0
 public void CreateChatRoom()
 {
     reference = FirebaseDatabase.DefaultInstance.GetReference("chatRooms");
     reference.GetValueAsync().ContinueWithOnMainThread(task =>
     {
         if (task.IsFaulted || task.IsCanceled)
         {
             Debug.Log("task failed");
         }
         else if (task.IsCompleted)
         {
             Debug.Log(roomIndex);
             DataSnapshot snapshot = task.Result;
             Debug.Log(task.Result);
             if (snapshot.Value != null)
             {
                 IDictionary temp = (IDictionary)snapshot.Value;
                 roomIndex        = temp.Count;
             }
             Debug.Log(roomIndex);
             ChatRoom chatRoom = new ChatRoom($"http://gravatar.com/avatar/{imageURL}?d=identicon", nicknameIF.text, "", nicknameIF.text + "의 방", UID, nicknameIF.text + "의 방", roomIndex);
             var chatRoomJson  = StringSerializationAPI.Serialize(typeof(ChatRoom), chatRoom);
             reference.Child(UID).SetRawJsonValueAsync(chatRoomJson);
             Debug.Log("채팅방 생성 완료");
             SetPlayerNameAndImage(nicknameIF.text, $"http://gravatar.com/avatar/{imageURL}?d=identicon");
             HumanAnimatorController.isJoin = true;
             JoinCanvas.SetActive(false);
             CharacterSelect.SetActive(true);
         }
     });
 }
    public static string ToJson_full <T>(T data)
    {
        var json = StringSerializationAPI.Serialize(typeof(T), data);

        // Assetsフォルダに保存する
        json = JsonFormatter.ToPrettyPrint(json, JsonFormatter.IndentType.Space);
        return(json);
    }
Example #3
0
        public SliderTree()
        {
            sliderNodeList = new Dictionary <string, SliderNode>();

            //in case the templates of these change.
            versionHash  = StringSerializationAPI.Serialize(typeof(SliderTree), this);
            versionHash += StringSerializationAPI.Serialize(typeof(SliderNode), new SliderNode());
        }
Example #4
0
        public void OnBeforeSerialize()
        {
            string s = StringSerializationAPI.Serialize(typeof(Type), type);

            if (s.StartsWith("\"") && s.EndsWith("\""))
            {
                s = s.Substring(1, s.Length - 2);
            }
            serializedType = s;
        }
        public void Save()
        {
            var    existingJson = EditorPrefs.GetString(typeof(AssetWindowOptions).Name);
            string json         = StringSerializationAPI.Serialize(this);

            if (existingJson != json)
            {
                Debug.Log(json);
                EditorPrefs.SetString(typeof(AssetWindowOptions).Name, json);
            }
        }
Example #6
0
    public static void SaveAction <T>(T data, string path)
    {
        var json = StringSerializationAPI.Serialize(typeof(T), data);

        // Assetsフォルダに保存する
        json = JsonFormatter.ToPrettyPrint(json, JsonFormatter.IndentType.Space);
        var savePath = GetPath(path);
        var writer   = new StreamWriter(savePath, false); // 上書き

        writer.WriteLine(json);
        writer.Flush();
        writer.Close();
    }
Example #7
0
    public void EditMessage(string messageId, string newText, Action callback, Action <AggregateException> fallback)
    {
        var messageJSON = StringSerializationAPI.Serialize(typeof(string), newText);

        reference.Child($"messages/{messageId}/text").SetRawJsonValueAsync(messageJSON).ContinueWith(task =>
        {
            if (task.IsCanceled || task.IsFaulted)
            {
                fallback(task.Exception);
            }
            else
            {
                callback();
            }
        });
    }
Example #8
0
    public void PostMessage(Message message, Action callback, Action <AggregateException> fallback)
    {
        var messageJSON = StringSerializationAPI.Serialize(typeof(Message), message);

        reference.Child("messages").Push().SetRawJsonValueAsync(messageJSON).ContinueWith(task =>
        {
            if (task.IsCanceled || task.IsFaulted)
            {
                fallback(task.Exception);
            }
            else
            {
                callback();
            }
        });
    }
Example #9
0
    public void PostUser(User user, Action callback, Action <AggregateException> fallback)
    {
        var messageJSON = StringSerializationAPI.Serialize(typeof(User), user);

        reference.Child($"users/{APIHandler.Instance.authAPI.GetUserID}").SetRawJsonValueAsync(messageJSON).ContinueWith(task =>
        {
            if (task.IsCanceled || task.IsFaulted)
            {
                fallback(task.Exception);
            }
            else
            {
                callback();
            }
        });
    }
Example #10
0
    public void SyncUnfold(UnfoldData data, Action <UnfoldData> callback, Action <AggregateException> fallback)
    {
        var json = StringSerializationAPI.Serialize(typeof(UnfoldData), data);

        reference.Child("worlds/world_1234/pieces").Push().SetRawJsonValueAsync(json).ContinueWith(task =>
        {
            if (task.IsCanceled || task.IsFaulted)
            {
                fallback(task.Exception);
            }
            else
            {
                callback(data);
            }
        });
    }
    public static void Save <T> (string path, T obj)
    {
        string fullPath = GetFullResourcesPath(path);
        // create serialized data
        string serialized = StringSerializationAPI.Serialize(typeof(T), obj);

        #if UNITY_EDITOR
        // create resources folder
        string pathParentName = Directory.GetParent(fullPath).FullName;
        if (!Directory.Exists(pathParentName))
        {
            Directory.CreateDirectory(pathParentName);
        }

        // write to file
        File.WriteAllText(GetFullResourcesPath(path) + ".txt", serialized);

        // refresh project window
        UnityEditor.AssetDatabase.Refresh();
        #endif
    }
Example #12
0
        // Saves the recipe that given as parameter
        public static void SaveRecipe(Recipe recipeToBeSaved)
        {
            // Serialize this recipe
            string recipeData = StringSerializationAPI.Serialize(typeof(Recipe), recipeToBeSaved);

            BinaryFormatter bf = new BinaryFormatter();
            FileStream      file;

            // If save file exists, open it
            if (File.Exists(Application.dataPath + "/Recipes/" + recipeToBeSaved.recipeName + ".vrcr"))
            {
                file = File.OpenWrite(Application.dataPath + "/Recipes/" + recipeToBeSaved.recipeName + ".vrcr");
            }
            // Save file doesn't exist, create new one.
            else
            {
                file = File.Create(Application.dataPath + "/Recipes/" + recipeToBeSaved.recipeName + ".vrcr");
            }

            bf.Serialize(file, recipeData);
            file.Close();
        }
Example #13
0
    public void PostMessage(Message message, Action callback, Action <AggregateException> fallback)
    {
        textIF.Select();
        //textIF.text = "";
        var    messageJSON = StringSerializationAPI.Serialize(typeof(Message), message); //Message 타입을 JSON으로 파싱
        string messageKey  = reference.Child("messages").Child(key).Push().Key;

        reference.Child("messages").Child(key).Child(messageKey).SetRawJsonValueAsync(messageJSON).ContinueWith(task =>
        {
            if (task.IsCanceled || task.IsFaulted)
            {
                fallback(task.Exception);
            }
            else
            {
                callback();
                reference.Child("messages").Child(key).Child(messageKey).UpdateChildrenAsync(new Dictionary <string, object> {
                    { "timestamp", ServerValue.Timestamp }
                }); //Timestamp 설정
            }
        });         //비동기 task로 DB에 추가
    }
 public void DisplayParameters() =>
 parametersText.text = "Parameters: " +
                       StringSerializationAPI.Serialize(typeof(Dictionary <string, string>), parameters);
Example #15
0
 public void SaveSliderTree(SliderTree toSave, string path = "/../Characters/", string name = "default")
 {
     File.WriteAllText(Application.dataPath + path + name + ".fwc", StringSerializationAPI.Serialize(typeof(SliderTree), toSave));
 }