Example #1
0
        public void DeserializationContext()
        {
            var migration = new TestMigrationContext();

            JsonSerialization.AddGlobalMigration(migration);

            File.WriteAllText(TestMigrationContext.k_AssetPath, $"{{\"Dependencies\": [], \"Components\": [{{\"$type\": {typeof(TestBuildComponentA).GetAssemblyQualifiedTypeName().DoubleQuotes()}}}]}}");
            AssetDatabase.ImportAsset(TestMigrationContext.k_AssetPath, ImportAssetOptions.ForceSynchronousImport | ImportAssetOptions.ForceUpdate);

            var asset = BuildConfiguration.LoadAsset(TestMigrationContext.k_AssetPath);

            Assert.That(asset.HasComponent <TestBuildComponentA>(), Is.True);
            Assert.That(asset.HasComponent <TestBuildComponentB>(), Is.True);

            AssetDatabase.DeleteAsset(TestMigrationContext.k_AssetPath);
            JsonSerialization.RemoveGlobalMigration(migration);
        }
 static void Register() => JsonSerialization.AddGlobalMigration(new SceneListMigration());