feat: Add audio import tool and standardize audio import settings
- Add editor tool to batch apply audio import settings based on configuration files - Standardize sample rates: SFX/Voice to 22050 Hz, Music to 44100 Hz - Set quality: SFX/Voice to 0.5, Music to 0.13 - Adjust load types based on audio duration - Set project sample rate to 48000 Hz - Update preload settings for voice and music files
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
using DG.Tweening;
|
||||
@@ -179,13 +178,33 @@ namespace OCES.Audio
|
||||
}
|
||||
}
|
||||
|
||||
static class AudioConfigLoader
|
||||
public static class AudioConfigLoader
|
||||
{
|
||||
public static Dictionary<uint, T> Load<T>(string path, Func<T, uint> keySelector)
|
||||
public static T Load<T>(string configPath, string fileName)
|
||||
where T : IBinarySerializable, new()
|
||||
{
|
||||
string json = System.IO.File.ReadAllText(path);
|
||||
var wrapper = JsonUtility.FromJson<AudioObjectArrayWrapper<T>>(json);
|
||||
return wrapper.AudioObjects.ToDictionary(keySelector);
|
||||
string path = Path.Combine(
|
||||
Application.dataPath, "Resources", configPath, fileName);
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Debug.LogError($"[AudioImportTool] 找不到配置文件: {path}");
|
||||
return default;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var config = new T();
|
||||
using var ms = new MemoryStream(File.ReadAllBytes(path));
|
||||
using var reader = new BinaryReader(ms);
|
||||
config.DeSerialize(reader);
|
||||
return config;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"[AudioImportTool] 配置表反序列化失败 {fileName}: {e.Message}");
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
public static T Load<T>(string tableName) where T : IBinarySerializable, new()
|
||||
|
||||
Reference in New Issue
Block a user