Exemplo n.º 1
0
        public object LoadAsset(AssetInfo assetInfo, IAssetStore assetStore)
        {
            using var assetFileStream = _fileSystem.GetFile(assetInfo.AssetFilePath).OpenRead();
            var assetData           = AssetData.Load(assetFileStream);
            var textureAssetContent = assetData.ReadJsonContent <TextureAssetContent>();

            if (textureAssetContent.TextureFilePath == null)
            {
                throw new InvalidOperationException($"{nameof(TextureAssetContent)}.{nameof(TextureAssetContent.TextureFilePath)} cannot be null.");
            }

            var textureFilePath = PathUtils.GetSiblingPath(assetInfo.AssetFilePath, textureAssetContent.TextureFilePath);

            using var textureFileStream = _fileSystem.GetFile(textureFilePath).OpenRead();
            return(_renderer2D.CreateTexture(textureFileStream));
        }