Exemplo n.º 1
0
        public void ClassWithUnityObject_WhenValueIsNull_CanBeSerializedAndDeserialized()
        {
            var src = new ClassWithUnityObjects();
            var dst = SerializeAndDeserialize(src);

            Assert.That(dst, Is.Not.SameAs(src));
            Assert.That(dst.ObjectValue, Is.EqualTo(src.ObjectValue));
        }
Exemplo n.º 2
0
        public void ClassWithUnityObject_WhenValueIsTexture2DAsset_CanBeSerializedAndDeserialized()
        {
            var image = new Texture2D(1, 1);

            AssetDatabase.CreateAsset(image, kTexture2DPath);
            AssetDatabase.ImportAsset(kTexture2DPath, ImportAssetOptions.ForceSynchronousImport | ImportAssetOptions.ForceUpdate);

            try
            {
                var src = new ClassWithUnityObjects
                {
                    ObjectValue = image
                };

                var dst = SerializeAndDeserialize(src);

                Assert.That(dst, Is.Not.SameAs(src));
                Assert.That(dst.ObjectValue, Is.EqualTo(src.ObjectValue));
            }
            finally
            {
                AssetDatabase.DeleteAsset(kTexture2DPath);
            }
        }