Added GenerateMask to AssetsHelpers;
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.ArtToolEditor
|
||||
{
|
||||
internal class CreateDecalMenu
|
||||
{
|
||||
[MenuItem("Assets/Art Tools/Material Helpers/Create Decal", true)]
|
||||
public static bool CreateDecalValidator()
|
||||
{
|
||||
foreach (var selectedObject in Selection.objects)
|
||||
{
|
||||
if (selectedObject is not Material)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Art Tools/Material Helpers/Create Decal")]
|
||||
public static void CreateDecal()
|
||||
{
|
||||
var createDecal = new CreateDecalMenu();
|
||||
var window = EditorWindow.GetWindow<OutputOptionsWindow>(true, "Decal Output Options");
|
||||
window.WithItemSource(Selection.objects);
|
||||
window.RegisterProcessor<CreateDecalProcessor>();
|
||||
|
||||
window.InitializeAndShow();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4585b41cdb0577478ac9c4e563dc639
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.HighDefinition;
|
||||
|
||||
namespace Misaki.ArtToolEditor
|
||||
{
|
||||
internal class CreateDecalProcessor : IAssetsProcessor
|
||||
{
|
||||
public void OnPreProcess(AssetsProcessContext context)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnProcess(UnityEngine.Object source, string outputDirectory, AssetsProcessContext context)
|
||||
{
|
||||
if (source is not Material mat)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var outputPath = Path.Combine(outputDirectory, mat.name + ".prefab");
|
||||
var decal = AssetCreationHelpers.CreateDecal(outputPath);
|
||||
|
||||
mat.shader = Shader.Find(Constants.Shader.DECAL_SHADER_PATH);
|
||||
decal.transform.rotation = Quaternion.Euler(90, 0, 0);
|
||||
decal.GetComponent<DecalProjector>().material = mat;
|
||||
}
|
||||
|
||||
public void OnPostProcess(AssetsProcessContext context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94792199a8319cd46b91c5b746992046
|
||||
Reference in New Issue
Block a user