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


C# Assets.Package类代码示例

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


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

示例1: Upgrade

        public override bool Upgrade(PackageSession session, ILogger log, Package dependentPackage, PackageDependency dependency, Package dependencyPackage, IList<PackageLoadingAssetFile> assetFiles)
        {
            // Paradox 1.1 projects didn't have their dependency properly updated (they might have been marked as 1.0).
            // We know they are 1.1 only because there is a .props file.
            // This check shouldn't be necessary from 1.2.
            var packagePath = dependentPackage.FullPath;
            var propsFilePath = UPath.Combine(packagePath.GetParent(), (UFile)(packagePath.GetFileName() + ".props"));
            if (!File.Exists(propsFilePath) && dependency.Version.MinVersion < new PackageVersion("1.1.0-beta"))
            {
                log.Error("Can't upgrade old projects from {0} 1.0 to 1.1", dependency.Name);
                return false;
            }

            // Nothing to do for now, most of the work is already done by individual asset upgraders
            // We can later add logic here for package-wide upgrades (i.e. GameSettingsAsset)
            if (dependency.Version.MinVersion < new PackageVersion("1.2.0-beta"))
            {
                // UIImageGroups and SpriteGroups asset have been merged into a single SpriteSheet => rename the assets and modify the tag
                var uiImageGroups = assetFiles.Where(f => f.FilePath.GetFileExtension() == ".pdxuiimage");
                var spitesGroups = assetFiles.Where(f => f.FilePath.GetFileExtension() == ".pdxsprite");
                RenameAndChangeTag(assetFiles, uiImageGroups, "!UIImageGroup");
                RenameAndChangeTag(assetFiles, spitesGroups, "!SpriteGroup");
            }

            return true;
        }
开发者ID:hck509,项目名称:paradox,代码行数:26,代码来源:ParadoxPackageUpgrader.cs

示例2: EffectCompileCommand

 public EffectCompileCommand(AssetCompilerContext context, UDirectory baseUrl, string effectName, CompilerParameters compilerParameters, Package package)
 {
     this.context = context;
     this.baseUrl = baseUrl;
     this.effectName = effectName;
     this.compilerParameters = compilerParameters;
     this.package = package;
 }
开发者ID:releed,项目名称:paradox,代码行数:8,代码来源:EffectCompileCommand.cs

示例3: AssetMigrationContext

 /// <summary>
 /// Initializes a new instance of <see cref="AssetMigrationContext"/>.
 /// </summary>
 /// <param name="package"></param>
 /// <param name="assetReference"></param>
 /// <param name="assetFullPath"></param>
 /// <param name="log"></param>
 public AssetMigrationContext(Package package, IReference assetReference, string assetFullPath, ILogger log)
 {
     if (log == null) throw new ArgumentNullException(nameof(log));
     Package = package;
     AssetReference = assetReference;
     AssetFullPath = assetFullPath;
     Log = new AssetLogger(package, assetReference, assetFullPath, log);
 }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:15,代码来源:AssetMigrationContext.cs

示例4: PackageLoadingAssetFile

        /// <summary>
        /// Initializes a new instance of the <see cref="PackageLoadingAssetFile" /> class.
        /// </summary>
        /// <param name="package">The package this asset will be part of.</param>
        /// <param name="filePath">The relative file path (from default asset folder).</param>
        /// <param name="sourceFolder">The source folder (optional, can be null).</param>
        /// <exception cref="System.ArgumentException">filePath must be relative</exception>
        public PackageLoadingAssetFile(Package package, UFile filePath, UDirectory sourceFolder)
        {
            if (filePath.IsAbsolute)
                throw new ArgumentException("filePath must be relative", filePath);

            SourceFolder = UPath.Combine(package.RootDirectory, sourceFolder ?? package.GetDefaultAssetFolder());
            FilePath = UPath.Combine(SourceFolder, filePath);
        }
开发者ID:robterrell,项目名称:paradox,代码行数:15,代码来源:PackageLoadingAssetFile.cs

示例5: AssetLogger

 public AssetLogger(Package package, IReference assetReference, string assetFullPath, ILogger loggerToForward)
 {
     this.package = package;
     this.assetReference = assetReference;
     this.assetFullPath = assetFullPath;
     this.loggerToForward = loggerToForward;
     ActivateLog(LogMessageType.Debug);
 }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:8,代码来源:AssetLogger.cs

示例6: PackageStore

        /// <summary>
        /// Initializes a new instance of the <see cref="PackageStore"/> class.
        /// </summary>
        /// <exception cref="System.InvalidOperationException">Unable to find a valid Xenko installation path</exception>
        private PackageStore(string installationPath = null, string defaultPackageName = "Xenko", string defaultPackageVersion = XenkoVersion.CurrentAsText)
        {
            // TODO: these are currently hardcoded to Xenko
            DefaultPackageName = defaultPackageName;
            DefaultPackageVersion = new PackageVersion(defaultPackageVersion);
            defaultPackageDirectory = DirectoryHelper.GetPackageDirectory(defaultPackageName);
   
            // 1. Try to use the specified installation path
            if (installationPath != null)
            {
                if (!DirectoryHelper.IsInstallationDirectory(installationPath))
                {
                    throw new ArgumentException("Invalid Xenko installation path [{0}]".ToFormat(installationPath), "installationPath");
                }

                globalInstallationPath = installationPath;
            }

            // 2. Try to resolve an installation path from the path of this assembly
            // We need to be able to use the package manager from an official Xenko install as well as from a developer folder
            if (globalInstallationPath == null)
            {
                globalInstallationPath = DirectoryHelper.GetInstallationDirectory(DefaultPackageName);
            }

            // If there is no root, this is an error
            if (globalInstallationPath == null)
            {
                throw new InvalidOperationException("Unable to find a valid Xenko installation or dev path");
            }

            // Preload default package
            var logger = new LoggerResult();
            var defaultPackageFile = DirectoryHelper.GetPackageFile(defaultPackageDirectory, DefaultPackageName);
            defaultPackage = Package.Load(logger, defaultPackageFile, GetDefaultPackageLoadParameters());
            if (defaultPackage == null)
            {
                throw new InvalidOperationException("Error while loading default package from [{0}]: {1}".ToFormat(defaultPackageFile, logger.ToText()));
            }
            defaultPackage.IsSystem = true;

            // A flag variable just to know if it is a bare bone development directory
            isDev = defaultPackageDirectory != null && DirectoryHelper.IsRootDevDirectory(defaultPackageDirectory);

            // Check if we are in a root directory with store/packages facilities
            if (NugetStore.IsStoreDirectory(globalInstallationPath))
            {
                packagesDirectory = UPath.Combine(globalInstallationPath, (UDirectory)NugetStore.DefaultGamePackagesDirectory);
                store = new NugetStore(globalInstallationPath);
            }
            else
            {
                // We should exit from here if NuGet is not configured.
                MessageBox.Show($"Unexpected installation. Cannot find a proper NuGet configuration for [{defaultPackageName}] in [{globalInstallationPath}]", "Installation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(1);
            }
        }
开发者ID:cg123,项目名称:xenko,代码行数:61,代码来源:PackageStore.cs

示例7: CreateCompilePackageFromAsset

        /// <summary>
        /// Create a <see cref="Package"/> that can be used to compile an <see cref="AssetItem"/> by analyzing and resolving its dependencies.
        /// </summary>
        /// <returns>The package packageSession that can be used to compile the asset item.</returns>
        public static Package CreateCompilePackageFromAsset(this PackageSession session, AssetItem originalAssetItem)
        {
            // create the compile root package and package session
            var assetPackageCloned = new Package();
            var compilePackageSession = new PackageSession(assetPackageCloned);

            AddAssetToCompilePackage(session, originalAssetItem, assetPackageCloned);

            return assetPackageCloned;
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:14,代码来源:PackageSession.Extensions.cs

示例8: FillPackageDependencies

        private static void FillPackageDependencies(Package rootPackage, bool isRecursive, ICollection<Package> packagesFound, bool storeOnly = false)
        {
            var session = rootPackage.Session;

            if (session == null && (rootPackage.Meta.Dependencies.Count > 0 || rootPackage.LocalDependencies.Count > 0))
            {
                throw new InvalidOperationException("Cannot query package with dependencies when it is not attached to a session");
            }

            // 1. Load store package
            foreach (var packageDependency in rootPackage.Meta.Dependencies)
            {
                var package = session.Packages.Find(packageDependency);
                if (package == null)
                {
                    continue;
                }

                if (!packagesFound.Contains(package))
                {
                    packagesFound.Add(package);

                    if (isRecursive)
                    {
                        FillPackageDependencies(package, isRecursive, packagesFound, storeOnly);
                    }
                }
            }

            if (storeOnly)
            {
                return;
            }

            // 2. Load local packages
            foreach (var packageReference in rootPackage.LocalDependencies)
            {
                var package = session.Packages.Find(packageReference.Id);
                if (package == null)
                {
                    continue;
                }

                if (!packagesFound.Contains(package))
                {
                    packagesFound.Add(package);

                    if (isRecursive)
                    {
                        FillPackageDependencies(package, isRecursive, packagesFound, storeOnly);
                    }
                }
            }

        }
开发者ID:Powerino73,项目名称:paradox,代码行数:55,代码来源:PackageExtensions.cs

示例9: PackageSession

 /// <summary>
 /// Initializes a new instance of the <see cref="PackageSession"/> class.
 /// </summary>
 public PackageSession(Package package)
 {
     packages = new PackageCollection();
     packagesCopy = new PackageCollection();
     assemblyContainer = new AssemblyContainer();
     packages.CollectionChanged += PackagesCollectionChanged;
     if (package != null)
     {
         Packages.Add(package);
     }            
 }
开发者ID:Powerino73,项目名称:paradox,代码行数:14,代码来源:PackageSession.cs

示例10: GetGraphicsPlatform

        public static GraphicsPlatform GetGraphicsPlatform(this AssetCompilerContext context, Package package)
        {
            // If we have a command line override, use it first
            string graphicsApi;
            if (context.OptionProperties.TryGetValue("SiliconStudioXenkoGraphicsApi", out graphicsApi))
                return (GraphicsPlatform)Enum.Parse(typeof(GraphicsPlatform), graphicsApi);

            // Ohterwise, use game settings, or default as fallback
            var settings = package.GetGameSettingsAsset();
            return settings == null ? context.Platform.GetDefaultGraphicsPlatform() : RenderingSettings.GetGraphicsPlatform(context.Platform, settings.Get<RenderingSettings>(context.Profile).PreferredGraphicsPlatform);
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:11,代码来源:AssetCompilerContextExtensions.cs

示例11: PackageSession

        /// <summary>
        /// Initializes a new instance of the <see cref="PackageSession"/> class.
        /// </summary>
        public PackageSession(Package package)
        {
            constraintProvider.AddConstraint(PackageStore.Instance.DefaultPackageName, new VersionSpec(PackageStore.Instance.DefaultPackageVersion.ToSemanticVersion()));

            packages = new PackageCollection();
            packagesCopy = new PackageCollection();
            assemblyContainer = new AssemblyContainer();
            packages.CollectionChanged += PackagesCollectionChanged;
            if (package != null)
            {
                Packages.Add(package);
            }            
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:16,代码来源:PackageSession.cs

示例12: UpgradeAfterAssetsLoaded

        /// <inheritdoc/>
        public override bool UpgradeAfterAssetsLoaded(PackageSession session, ILogger log, Package dependentPackage, PackageDependency dependency, Package dependencyPackage, PackageVersionRange dependencyVersionBeforeUpdate)
        {
            if (dependencyVersionBeforeUpdate.MinVersion < new PackageVersion("1.3.0-alpha02"))
            {
                // Add everything as root assets (since we don't know what the project was doing in the code before)
                foreach (var assetItem in dependentPackage.Assets)
                {
                    if (!AssetRegistry.IsAssetTypeAlwaysMarkAsRoot(assetItem.Asset.GetType()))
                        dependentPackage.RootAssets.Add(new AssetReference<Asset>(assetItem.Id, assetItem.Location));
                }
            }

            return true;
        }
开发者ID:RxGamesLtd,项目名称:paradox,代码行数:15,代码来源:ParadoxPackageUpgrader.cs

示例13: TrackPackage

        /// <summary>
        /// This method is called when a package needs to be tracked
        /// </summary>
        /// <param name="package">The package to track.</param>
        private void TrackPackage(Package package)
        {
            if (packages.Contains(package))
                return;

            packages.Add(package);

            foreach (var asset in package.Assets)
            {
                TrackAsset(asset);
            }

            package.Assets.CollectionChanged += Assets_CollectionChanged;
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:18,代码来源:AssetTracker.cs

示例14: AddLoadingFromSession

        public static void AddLoadingFromSession(this ShaderGeneratorContextBase context, Package package)
        {
            var previousGetAssetFriendlyName = context.GetAssetFriendlyName;
            var previousFindAsset = context.FindAsset;

            // Setup the GetAssetFriendlyName callback
            context.GetAssetFriendlyName = runtimeAsset =>
            {
                string assetFriendlyName = null;

                if (previousGetAssetFriendlyName != null)
                {
                    assetFriendlyName = previousGetAssetFriendlyName(runtimeAsset);
                }

                if (string.IsNullOrEmpty(assetFriendlyName))
                {
                    var referenceAsset = AttachedReferenceManager.GetAttachedReference(runtimeAsset);
                    assetFriendlyName = string.Format("{0}:{1}", referenceAsset.Id, referenceAsset.Url);
                }

                return assetFriendlyName;
            };

            // Setup the FindAsset callback
            context.FindAsset = runtimeAsset =>
            {
                object newAsset = null; 
                if (previousFindAsset != null)
                {
                    newAsset = previousFindAsset(runtimeAsset);
                }

                if (newAsset != null)
                {
                    return newAsset;
                }

                var reference = AttachedReferenceManager.GetAttachedReference(runtimeAsset);


                var assetItem = package.Session.FindAsset(reference.Id) ?? package.Session.FindAsset(reference.Url);

                if (assetItem == null)
                {
                    return null;
                }
                return assetItem.Asset;
            };            
        }
开发者ID:Julyuary,项目名称:paradox,代码行数:50,代码来源:ShaderGeneratorContextExtensions.cs

示例15: UnTrackPackage

        /// <summary>
        /// This method is called when a package needs to be un-tracked
        /// </summary>
        /// <param name="package">The package to un-track.</param>
        private void UnTrackPackage(Package package)
        {
            if (!packages.Contains(package))
                return;

            package.Assets.CollectionChanged -= Assets_CollectionChanged;

            foreach (var asset in package.Assets)
            {
                UnTrackAsset(asset);
            }

            packages.Remove(package);
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:18,代码来源:AssetTracker.cs


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