Convert svg color to a sound texture folder

This commit is contained in:
Banane_Rotative
2025-11-15 16:23:36 +01:00
parent 03b42a65e5
commit 0b0cfa516b
9 changed files with 100 additions and 2 deletions

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
[CreateAssetMenu(fileName = "ColorFolderMap", menuName = "Config/Color Folder Map")]
public class ColorFolderMap : ScriptableObject {
[Serializable]
public struct Entry {
public Color color;
public string folderName; // Example: "Gravel"
}
private const string SoundTexturesFolder = "Sound/Textures/";
public List<Entry> entries = new List<Entry>();
/// Returns folder path for color, or null if not found (Editor + Runtime safe)
public string GetFolder(Color color) {
string hexColor = color.ToHexString();
foreach (var entry in entries) {
if (entry.color.ToHexString() == hexColor) {
return SoundTexturesFolder + entry.folderName;
}
}
return null;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 915ff3c5d25a0b44e89c7e267f66e4d4

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b55fda8cdee81ea43b73610114e83bb2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 915ff3c5d25a0b44e89c7e267f66e4d4, type: 3}
m_Name: ColorFolderMap
m_EditorClassIdentifier:
entries:
- color: {r: 0.8784314, g: 0.44313726, b: 0.53333336, a: 1}
folderName: Gravel

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bc3bfa2a0f7c8b949a39e040c0579741
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -23,6 +23,8 @@ public class SvgToFlatMeshEditor : EditorWindow
SamplingStepSize = 0.01f
};
[SerializeField] private ColorFolderMap colorFolderMap;
[MenuItem("Tools/SVG → Flat Mesh Regions")]
static void OpenWindow() {
var w = GetWindow<SvgToFlatMeshEditor>("SVG → Flat Mesh");
@@ -160,7 +162,12 @@ public class SvgToFlatMeshEditor : EditorWindow
// Add tag to disable mesh renderer before build
go.tag = "EditorOnlyMeshRenderer";
// TODO: automatically assign audio triggers based on color
// Automatically assign audio triggers based on color
string folder = colorFolderMap.GetFolder(color);
if (folder != null)
{
// TODO: automatically assign audio triggers
}
}
// Focus selection on created container

View File

@@ -1,2 +1,13 @@
fileFormatVersion: 2
guid: 9264c9156cb5dbc4cbfeaaa27c0ab93b
guid: 9264c9156cb5dbc4cbfeaaa27c0ab93b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- m_ViewDataDictionary: {instanceID: 0}
- colorFolderMap: {fileID: 11400000, guid: bc3bfa2a0f7c8b949a39e040c0579741, type: 2}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f3a8210de0ae1ce44ac831ac99d756a7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 45cc896a8d2b9de4b85f5c96b530f0f4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: