Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d07c6da

Browse files
committed
add code for a raw texture exporter
1 parent 7221480 commit d07c6da

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using AssetRipper.Core.Classes.Texture2D;
2+
using AssetRipper.Core.Interfaces;
3+
using AssetRipper.Core.Project.Collections;
4+
using AssetRipper.Core.Project.Exporters;
5+
6+
namespace AssetRipper.Library.Exporters.Textures
7+
{
8+
internal class RawTextureExportCollection : AssetExportCollection
9+
{
10+
public RawTextureExportCollection(IAssetExporter assetExporter, ITexture2D asset) : base(assetExporter, asset)
11+
{
12+
}
13+
14+
protected override string GetExportExtension(IUnityObjectBase asset)
15+
{
16+
return ((ITexture2D)asset).TextureFormat.ToString();
17+
}
18+
}
19+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using AssetRipper.Core.Classes.Texture2D;
2+
using AssetRipper.Core.Interfaces;
3+
using AssetRipper.Core.Parser.Files.SerializedFiles;
4+
using AssetRipper.Core.Project;
5+
using AssetRipper.Core.Project.Collections;
6+
using AssetRipper.Core.Project.Exporters;
7+
using System.IO;
8+
9+
namespace AssetRipper.Library.Exporters.Textures
10+
{
11+
internal class RawTextureExporter : BinaryAssetExporter
12+
{
13+
public override bool IsHandle(IUnityObjectBase asset)
14+
{
15+
return asset is ITexture2D;
16+
}
17+
18+
public override bool Export(IExportContainer container, IUnityObjectBase asset, string path)
19+
{
20+
File.WriteAllBytes(path, ((ITexture2D)asset).GetImageData());
21+
return true;
22+
}
23+
24+
public override IExportCollection CreateCollection(VirtualSerializedFile virtualFile, IUnityObjectBase asset)
25+
{
26+
return new RawTextureExportCollection(this, (ITexture2D)asset);
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)