mirror of
https://github.com/appen-isen/jeu-sans-image.git
synced 2026-03-18 21:50:42 +01:00
Create color folder if non-existent
This commit is contained in:
@@ -12,18 +12,30 @@ public class ColorFolderMap : ScriptableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private const string SoundTexturesFolder = "Sound/Textures/";
|
private const string SoundTexturesFolder = "Sound/Textures/";
|
||||||
|
private const string ResourcesFolderPath = "Assets/Resources/";
|
||||||
|
|
||||||
public List<Entry> entries = new List<Entry>();
|
public List<Entry> entries = new List<Entry>();
|
||||||
|
|
||||||
/// Returns folder path for color, or null if not found (Editor + Runtime safe)
|
/// Returns folder path for color, or null if config not set (Editor + Runtime safe)
|
||||||
|
/// Creates the folder if it does not exist
|
||||||
public string GetFolder(Color color) {
|
public string GetFolder(Color color) {
|
||||||
string hexColor = color.ToHexString();
|
string hexColor = color.ToHexString();
|
||||||
foreach (var entry in entries) {
|
foreach (var entry in entries) {
|
||||||
if (entry.color.ToHexString() == hexColor) {
|
if (entry.color.ToHexString() == hexColor) {
|
||||||
|
CreateFolderIfNonExistent(entry.folderName);
|
||||||
return SoundTexturesFolder + entry.folderName;
|
return SoundTexturesFolder + entry.folderName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CreateFolderIfNonExistent(string folderName) {
|
||||||
|
#if UNITY_EDITOR // AssetDatabase is Editor-only
|
||||||
|
if (!UnityEditor.AssetDatabase.IsValidFolder(ResourcesFolderPath + SoundTexturesFolder + folderName)) {
|
||||||
|
UnityEditor.AssetDatabase.CreateFolder(ResourcesFolderPath + SoundTexturesFolder, folderName);
|
||||||
|
UnityEditor.AssetDatabase.Refresh();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user