Exemple #1
0
    public void PropertyValueJson()
    {
        PropertyAssignment before = new PropertyAssignment();

        before.propertyName = "health";
        before.SetValue <int>(42);

        string             json  = JsonUtility.ToJson(before);
        PropertyAssignment after = JsonUtility.FromJson <PropertyAssignment>(json);

        Assert.AreEqual(42, after.GetValue <int>());
        Assert.AreEqual("health", after.propertyName);
    }
Exemple #2
0
    public void BuildPropertyBlockJson()
    {
        PropertyAssignment health = new PropertyAssignment();

        health.propertyName = "health";
        health.SetValue <int>(42);

        PropertyAssignment friend = new PropertyAssignment();

        friend.propertyName = "friend";
        friend.SetValue <string>("alice");

        PropertyAssignment[] all = new PropertyAssignment[] { health, friend };

        string json = PropertyAssignment.BuildPropertyBlockJson(all);

        Debug.Log(json);

        TestPropertyBlock after = JsonUtility.FromJson <TestPropertyBlock>(json);

        Assert.AreEqual(42, after.health.value);
        Assert.AreEqual("alice", after.friend.value);
    }