Added base block textures and materials

This commit is contained in:
raccoon
2025-05-03 18:39:05 +05:00
parent a73788eb3a
commit 62c6d58e6b
525 changed files with 30499 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
using UnityEngine;
using UnityEditor;
public class MaterialGenerator
{
[MenuItem("Assets/Create/Materials from selected")]
private static void CreateMaterials()
{
foreach (Object obj in Selection.objects)
{
// TODO: Make better filtering
if (obj.GetType() != typeof(Texture2D) || obj.name.EndsWith("_metallic") || obj.name.EndsWith("_emissive"))
{
continue;
}
var selectedTex = obj as Texture2D;
var colorPath = AssetDatabase.GetAssetPath(selectedTex);
var basePath = colorPath.Substring(0, colorPath.LastIndexOf('/') + 1) + "mat/";
var metalPath = colorPath.Substring(0, colorPath.LastIndexOf('.')) + "_metallic.png";
var emissionPath = colorPath.Substring(0, colorPath.LastIndexOf('.')) + "_emissive.png";
var material = new Material(Shader.Find("Standard"));
material.mainTexture = selectedTex;
material.SetTexture("_MetallicGlossMap", EditorGUIUtility.FindTexture(metalPath));
material.SetTexture("_EmissionMap", EditorGUIUtility.FindTexture(emissionPath));
var newAssetName = basePath + selectedTex.name + ".mat";
AssetDatabase.CreateAsset(material, newAssetName);
}
AssetDatabase.SaveAssets();
}
}