Exemple #1
0
        private static Asset LoadAsset(ILogger log, string assetFullPath, string assetPath, UFile fileUPath)
        {
            AssetMigration.MigrateAssetIfNeeded(log, assetFullPath);

            var asset = AssetSerializer.Load <Asset>(assetFullPath);

            // Set location on source code asset
            var sourceCodeAsset = asset as SourceCodeAsset;

            if (sourceCodeAsset != null)
            {
                // Use an id generated from the location instead of the default id
                sourceCodeAsset.Id = SourceCodeAsset.GenerateGuidFromLocation(assetPath);
                sourceCodeAsset.AbsoluteSourceLocation = fileUPath;
            }

            return(asset);
        }
Exemple #2
0
        private static Asset LoadAsset(ILogger log, string assetFullPath, string assetPath, UFile fileUPath, byte[] assetContent)
        {
            var asset = assetContent != null
                ? (Asset)AssetSerializer.Load(new MemoryStream(assetContent), Path.GetExtension(assetFullPath), log)
                : AssetSerializer.Load <Asset>(assetFullPath, log);

            // Set location on source code asset
            var sourceCodeAsset = asset as SourceCodeAsset;

            if (sourceCodeAsset != null)
            {
                // Use an id generated from the location instead of the default id
                sourceCodeAsset.Id = SourceCodeAsset.GenerateGuidFromLocation(assetPath);
                sourceCodeAsset.AbsoluteSourceLocation = fileUPath;
            }

            return(asset);
        }