So I just realised that this asset doesn't have the feature of bulk creating multiple Bloxel textures at once, so I made this script:
using UnityEngine;
using UnityEditor;
using System.IO;
using RatKing.Bloxels;
using System.Collections.Generic;
public class TextureCreation : EditorWindow
{
public string textureFolder = "Assets/Textures";
public string outputFolder = "Assets/Resources/BloxelTextures";
public int atlasIndex = 2;
[MenuItem("Tools/Bloxel/Create BloxelTextures")]
public static void OpenWindow()
{
GetWindow<TextureCreation>("Bloxel Texture Generator");
}
private SerializedObject window;
private void OnEnable()
{
window = new SerializedObject(this);
}
private void OnGUI()
{
GUILayout.Label("Bloxel Texture Generator", EditorStyles.boldLabel);
GUILayout.Label("Make sure you have a inspector tab enable on screen", EditorStyles.miniLabel);
textureFolder = EditorGUILayout.TextField("Input Folder", textureFolder);
outputFolder = EditorGUILayout.TextField("Output Folder", outputFolder);
atlasIndex = EditorGUILayout.IntField("Atlas Index", atlasIndex);
if (GUILayout.Button("Generate BloxelTextures"))
{
CreateBloxelTextureData();
}
window.ApplyModifiedProperties();
}
public void CreateBloxelTextureData()
{
if (!Directory.Exists(textureFolder))
{
Debug.LogError($"Input folder not found: {textureFolder}");
return;
}
string[] subFolders = Directory.GetDirectories(textureFolder);
int index = 1;
List<Object> createdAssets = new List<Object>();
foreach (string folder in subFolders)
{
string folderName = Path.GetFileName(folder);
string[] textureFiles = Directory.GetFiles(folder, "*.png");
string savePath = Path.Combine(outputFolder, $"{index:D2}_{folderName}");
if (!Directory.Exists(savePath))
{
Directory.CreateDirectory(savePath);
}
foreach (string texPath in textureFiles)
{
string assetPath = texPath.Replace("\\", "/");
Texture2D texture = AssetDatabase.LoadAssetAtPath<Texture2D>(assetPath);
if (texture == null)
{
Debug.LogWarning($"Skipping non-texture file: {assetPath}");
continue;
}
string texName = "blx_" + Path.GetFileNameWithoutExtension(assetPath);
BloxelTexture bloxelTex = ScriptableObject.CreateInstance<BloxelTexture>();
bloxelTex.ID = Path.GetFileNameWithoutExtension(assetPath);
bloxelTex.texture = texture;
bloxelTex.texAtlasIdx = atlasIndex;
string finalPath = Path.Combine(savePath, texName + ".asset").Replace("\\", "/");
if (File.Exists(finalPath))
{
Debug.Log($"Skipped existing BloxelTexture: {finalPath}");
continue;
}
AssetDatabase.CreateAsset(bloxelTex, finalPath);
createdAssets.Add(bloxelTex);
Debug.Log($"Created BloxelTexture: {finalPath}");
}
index++;
}
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
if (createdAssets.Count > 0)
{
ShowAssetsSequentially(createdAssets, 0);
}
Debug.Log("Checking textures, please wait...");
}
private void ShowAssetsSequentially(List<Object> assets, int index)
{
if (index >= assets.Count)
{
Debug.Log("BloxelTexture generation complete.");
return;
}
Selection.activeObject = assets[index];
EditorGUIUtility.PingObject(assets[index]);
EditorApplication.delayCall += () =>
{
ShowAssetsSequentially(assets, index + 1);
};
}
}
Hope one day you can make this a feature in the next update