当前位置: 首页>>代码示例>>C#>>正文


C# Assets.AssetMigrationContext类代码示例

本文整理汇总了C#中SiliconStudio.Assets.AssetMigrationContext的典型用法代码示例。如果您正苦于以下问题:C# AssetMigrationContext类的具体用法?C# AssetMigrationContext怎么用?C# AssetMigrationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AssetMigrationContext类属于SiliconStudio.Assets命名空间,在下文中一共展示了AssetMigrationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Upgrade

        public void Upgrade(AssetMigrationContext context, string dependencyName, PackageVersion currentVersion, PackageVersion targetVersion, YamlMappingNode yamlAssetNode, PackageLoadingAssetFile assetFile)
        {
            dynamic asset = new DynamicYamlMapping(yamlAssetNode);

            // upgrade the asset
            UpgradeAsset(context, currentVersion, targetVersion, asset, assetFile);
            SetSerializableVersion(asset, dependencyName, targetVersion);

            // upgrade its base
            var baseBranch = asset[Asset.BaseProperty];
            if (baseBranch != null)
            {
                UpgradeBase(context, dependencyName, currentVersion, targetVersion, baseBranch, assetFile);
            }

            // upgrade base parts
            var basePartsBranch = asset[Asset.BasePartsProperty] as DynamicYamlArray;
            if (basePartsBranch != null)
            {
                foreach (dynamic assetBase in basePartsBranch)
                {
                    UpgradeBase(context, dependencyName, currentVersion, targetVersion, assetBase, assetFile);
                }
            }
        }
开发者ID:psowinski,项目名称:xenko,代码行数:25,代码来源:AssetUpgraderBase.cs

示例2: Upgrade

        public void Upgrade(AssetMigrationContext context, string dependencyName, PackageVersion currentVersion, PackageVersion targetVersion, YamlMappingNode yamlAssetNode, PackageLoadingAssetFile assetFile)
        {
            dynamic asset = new DynamicYamlMapping(yamlAssetNode);

            // upgrade the asset
            var baseBranch = asset[Asset.BaseProperty];
            var basePartsBranch = asset[Asset.BasePartsProperty] as DynamicYamlArray;

            // Detect in what kind of override context we are
            var overrideHint = (baseBranch != null || (basePartsBranch != null && basePartsBranch.Node.Children.Count > 0))
                ? OverrideUpgraderHint.Derived
                : OverrideUpgraderHint.Unknown;

            // Upgrade the asset
            UpgradeAsset(context, currentVersion, targetVersion, asset, assetFile, overrideHint);
            SetSerializableVersion(asset, dependencyName, targetVersion);

            // Upgrade its base
            if (baseBranch != null)
            {
                UpgradeBase(context, dependencyName, currentVersion, targetVersion, baseBranch, assetFile);
            }

            // Upgrade base parts
            if (basePartsBranch != null)
            {
                foreach (dynamic assetBase in basePartsBranch)
                {
                    UpgradeBase(context, dependencyName, currentVersion, targetVersion, assetBase, assetFile);
                }
            }
        }
开发者ID:cg123,项目名称:xenko,代码行数:32,代码来源:AssetUpgraderBase.cs

示例3: Test

        public void Test()
        {
            var logger = new LoggerResult();
            var context = new AssetMigrationContext(null, logger);

            var files = Directory.EnumerateFiles(@"..\..\samples", "*.xkscene", SearchOption.AllDirectories);

            foreach (var sceneFile in files)
            {
                logger.HasErrors = false;
                logger.Clear();
                Console.WriteLine($"Checking file {sceneFile}");

                var file = new PackageLoadingAssetFile(sceneFile, null);

                var needMigration = AssetMigration.MigrateAssetIfNeeded(context, file, "Xenko");

                foreach (var message in logger.Messages)
                {
                    Console.WriteLine(message);
                }

                Assert.False(logger.HasErrors);

                if (needMigration)
                {
                    var result = Encoding.UTF8.GetString(file.AssetContent);
                    Console.WriteLine(result);

                    // We cannot load the Package here, as the package can use code/scripts that are only available when you actually compile project assmeblies
                }
            }
        }
开发者ID:psowinski,项目名称:xenko,代码行数:33,代码来源:TestSceneUpgrader.cs

示例4: UpgradeAsset

 protected override void UpgradeAsset(AssetMigrationContext context, int currentVersion, int targetVersion, dynamic asset, PackageLoadingAssetFile assetFile)
 {
     if (asset.Source != null)
         asset.Source = DynamicYamlEmpty.Default;
     if (asset.SourceHash != null)
         asset.SourceHash = DynamicYamlEmpty.Default;
 }
开发者ID:releed,项目名称:paradox,代码行数:7,代码来源:SceneAsset.cs

示例5: UpgradeAsset

 protected override void UpgradeAsset(AssetMigrationContext context, int currentVersion, int targetVersion, dynamic asset, PackageLoadingAssetFile assetFile)
 {
     // Introduction of MaterialInstance
     var material = asset.Type.Material;
     if (material != null)
     {
         asset.Type.MaterialInstance = new YamlMappingNode();
         asset.Type.MaterialInstance.Material = material;
         asset.Type.Material = DynamicYamlEmpty.Default;
     }
     var type = asset.Type.Node as YamlMappingNode;
     if (type != null && type.Tag == "!CubeProceduralModel")
     {
         // Size changed from scalar to vector3
         var size = asset.Type.Size as DynamicYamlScalar;
         if (size != null)
         {
             var vecSize = new YamlMappingNode
             {
                 { new YamlScalarNode("X"), new YamlScalarNode(size.Node.Value) },
                 { new YamlScalarNode("Y"), new YamlScalarNode(size.Node.Value) },
                 { new YamlScalarNode("Z"), new YamlScalarNode(size.Node.Value) }
             };
             vecSize.Style = YamlStyle.Flow;
             asset.Type.Size = vecSize;
         }
     }
 }
开发者ID:Aff1ic7i0n,项目名称:paradox,代码行数:28,代码来源:ProceduralModelAsset.cs

示例6: UpgradeBase

 private void UpgradeBase(AssetMigrationContext context, string dependencyName, PackageVersion currentVersion, PackageVersion targetVersion, dynamic assetBase, PackageLoadingAssetFile assetFile)
 {
     var baseAsset = assetBase[nameof(AssetBase.Asset)];
     if (baseAsset != null)
     {
         UpgradeAsset(context, currentVersion, targetVersion, baseAsset, assetFile);
         SetSerializableVersion(baseAsset, dependencyName, targetVersion);
     }
 }
开发者ID:psowinski,项目名称:xenko,代码行数:9,代码来源:AssetUpgraderBase.cs

示例7: Upgrade

            public void Upgrade(AssetMigrationContext context, int currentVersion, int targetVersion, YamlMappingNode yamlAssetNode, PackageLoadingAssetFile assetFile)
            {
                dynamic asset = new DynamicYamlMapping(yamlAssetNode);
                var baseBranch = asset["~Base"];
                if (baseBranch != null)
                    asset["~Base"] = DynamicYamlEmpty.Default;

                SetSerializableVersion(asset, targetVersion);
            }
开发者ID:releed,项目名称:paradox,代码行数:9,代码来源:SceneAsset.cs

示例8: Upgrade

            public void Upgrade(AssetMigrationContext context, string dependencyName, PackageVersion currentVersion, PackageVersion targetVersion, YamlMappingNode yamlAssetNode, PackageLoadingAssetFile assetFile)
            {
                dynamic asset = new DynamicYamlMapping(yamlAssetNode);
                var baseBranch = asset[Asset.BaseProperty];
                if (baseBranch != null)
                    asset[BaseProperty] = DynamicYamlEmpty.Default;

                AssetUpgraderBase.SetSerializableVersion(asset, dependencyName, targetVersion);
            }
开发者ID:psowinski,项目名称:xenko,代码行数:9,代码来源:SceneAsset.Upgraders.cs

示例9: UpgradeAsset

 protected override void UpgradeAsset(AssetMigrationContext context, PackageVersion currentVersion, PackageVersion targetVersion, dynamic asset, PackageLoadingAssetFile assetFile, OverrideUpgraderHint overrideHint)
 {
     var hierarchy = asset.Hierarchy;
     var entities = (DynamicYamlArray)hierarchy.Entities;
     foreach (dynamic entity in entities)
     {
         var components = entity.Components;
         var modelComponent = components["ModelComponent.Key"];
         if (modelComponent != null)
             modelComponent.RemoveChild("DrawOrder");
     }
 }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:12,代码来源:SceneAsset.Upgraders.cs

示例10: UpgradeAsset

 protected override void UpgradeAsset(AssetMigrationContext context, PackageVersion currentVersion, PackageVersion targetVersion, dynamic asset, PackageLoadingAssetFile assetFile)
 {
     var hierarchy = asset.Hierarchy;
     var entities = (DynamicYamlArray)hierarchy.Entities;
     foreach (dynamic entity in entities)
     {
         var components = entity.Components;
         var spriteComponent = components["SpriteComponent.Key"];
         if (spriteComponent != null)
             spriteComponent.RemoveChild("ExtrusionMethod");
     }
 }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:12,代码来源:SceneAsset.Upgraders.cs

示例11: UpgradeAsset

            protected override void UpgradeAsset(AssetMigrationContext context, PackageVersion currentVersion, PackageVersion targetVersion, dynamic asset, PackageLoadingAssetFile assetFile,
                OverrideUpgraderHint overrideHint)
            {
                if (asset.IsDynamic != null)
                {
                    var isDynamic = (bool)asset.IsDynamic;

                    // There is also SDF type, but old assets don't have it yet
                    asset.AddChild("FontType", isDynamic ? "Dynamic" : "Static");

                    asset.RemoveChild("IsDynamic");
                }
            }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:13,代码来源:SpriteFontAsset.Upgrader.cs

示例12: UpgradeAsset

 protected override void UpgradeAsset(AssetMigrationContext context, PackageVersion currentVersion, PackageVersion targetVersion, dynamic asset, PackageLoadingAssetFile assetFile)
 {
     foreach (var modelMaterial in asset.Materials)
     {
         var material = modelMaterial.Material;
         if (material != null)
         {
             modelMaterial.MaterialInstance = new YamlMappingNode();
             modelMaterial.MaterialInstance.Material = material;
             modelMaterial.Material = DynamicYamlEmpty.Default;
         }
     }
 }
开发者ID:FERRERDEV,项目名称:xenko,代码行数:13,代码来源:ModelAsset.cs

示例13: Upgrade

        public void Upgrade(AssetMigrationContext context, int currentVersion, int targetVersion, YamlMappingNode yamlAssetNode, PackageLoadingAssetFile assetFile)
        {
            dynamic asset = new DynamicYamlMapping(yamlAssetNode);

            // upgrade the asset
            UpgradeAsset(context, currentVersion, targetVersion, asset, assetFile);
            SetSerializableVersion(asset, targetVersion);
            // upgrade its base
            var baseBranch = asset["~Base"];
            if (baseBranch != null)
            {
                var baseAsset = baseBranch["Asset"];
                if (baseAsset != null)
                    UpgradeAsset(context, currentVersion, targetVersion, baseAsset, assetFile);
                SetSerializableVersion(baseAsset, targetVersion);
            }
        }
开发者ID:releed,项目名称:paradox,代码行数:17,代码来源:AssetUpgraderBase.cs

示例14: UpgradeAsset

            protected override void UpgradeAsset(AssetMigrationContext context, PackageVersion currentVersion, PackageVersion targetVersion, dynamic asset, PackageLoadingAssetFile assetFile)
            {
                if (asset.ColliderShapes == null)
                    return;

                foreach (var colliderShape in asset.ColliderShapes)
                {
                    if (colliderShape.Node.Tag == "!Box2DColliderShapeDesc")
                    {
                        var size = 2f * DynamicYamlExtensions.ConvertTo<Vector2>(colliderShape.HalfExtent);
                        colliderShape.Size = DynamicYamlExtensions.ConvertFrom(size);
                        colliderShape.HalfExtent = DynamicYamlEmpty.Default;
                    }
                    if (colliderShape.Node.Tag == "!BoxColliderShapeDesc")
                    {
                        var size = 2f * DynamicYamlExtensions.ConvertTo<Vector3>(colliderShape.HalfExtents);
                        colliderShape.Size = DynamicYamlExtensions.ConvertFrom(size);
                        colliderShape.HalfExtents = DynamicYamlEmpty.Default;
                    }
                    if (colliderShape.Node.Tag == "!CapsuleColliderShapeDesc" || colliderShape.Node.Tag == "!CylinderColliderShapeDesc")
                    {
                        var upVector = DynamicYamlExtensions.ConvertTo<Vector3>(colliderShape.UpAxis);
                        if (upVector == Vector3.UnitX)
                            colliderShape.Orientation = ShapeOrientation.UpX;
                        if (upVector == Vector3.UnitZ)
                            colliderShape.Orientation = ShapeOrientation.UpZ;

                        colliderShape.UpAxis = DynamicYamlEmpty.Default;
                    }
                    if (colliderShape.Node.Tag == "!CapsuleColliderShapeDesc" && colliderShape.Height != null)
                    {
                        colliderShape.Length = 2f * (float)colliderShape.Height;
                        colliderShape.Height = DynamicYamlEmpty.Default;
                    }
                    if (colliderShape.Node.Tag == "!CylinderColliderShapeDesc")
                    {
                        colliderShape.Radius = (float)colliderShape.HalfExtents.X;
                        colliderShape.Height = 2f * (float)colliderShape.HalfExtents.Y;
                        colliderShape.HalfExtents = DynamicYamlEmpty.Default;
                    }
                }
            }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:42,代码来源:ColliderShapeAsset.cs

示例15: UpgradeAsset

            protected override void UpgradeAsset(AssetMigrationContext context, PackageVersion currentVersion, PackageVersion targetVersion, dynamic asset, PackageLoadingAssetFile assetFile,
                OverrideUpgraderHint overrideHint)
            {
                var hierarchy = asset.Hierarchy;
                var entities = hierarchy.Entities;
                foreach (var entityAndDesign in entities)
                {
                    var entity = entityAndDesign.Entity;
                    foreach (var component in entity.Components)
                    {
                        var componentTag = component.Node.Tag;
                        if (componentTag != "!SpriteComponent")
                            continue;

                        var provider = component.SpriteProvider;
                        if (provider == null || provider.Node.Tag != "!SpriteFromSheet")
                            continue;

                        component.TransferChild("CurrentFrame", provider, "CurrentFrame");
                    }
                }
            }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:22,代码来源:EntityHierarchyAssetBase.Upgraders.cs


注:本文中的SiliconStudio.Assets.AssetMigrationContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。