38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using System.IO;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace Misaki.ArtToolEditor
|
|
{
|
|
internal class CreateTerrainLayerProcessor : IAssetsProcessor
|
|
{
|
|
private const string Terrain_Layer_Extension = ".terrainlayer";
|
|
|
|
public void OnPreProcess(AssetsProcessContext context)
|
|
{
|
|
}
|
|
|
|
public void OnProcess(UnityEngine.Object source, string outputDirectory, AssetsProcessContext context)
|
|
{
|
|
if (source is not Material mat)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var terrainLayer = new TerrainLayer()
|
|
{
|
|
diffuseTexture = mat.GetTexture("_BaseColorMap") as Texture2D,
|
|
normalMapTexture = mat.GetTexture("_NormalMap") as Texture2D,
|
|
maskMapTexture = mat.GetTexture("_MaskMap") as Texture2D,
|
|
};
|
|
|
|
var outputPath = Path.Combine(outputDirectory, mat.name + Terrain_Layer_Extension);
|
|
AssetDatabase.CreateAsset(terrainLayer, outputPath);
|
|
}
|
|
|
|
public void OnPostProcess(AssetsProcessContext context)
|
|
{
|
|
}
|
|
}
|
|
}
|