1using System.Collections.Generic;
7using Sirenix.OdinInspector;
8using Sirenix.OdinInspector.Editor;
17 public class VoiceOverImporterWindow : OdinEditorWindow
19 public const string VoiceOverDataPath =
"Assets/VoiceOverData";
21 [Sirenix.OdinInspector.FilePath(Extensions =
"csv")]
22 public string filePath;
24 [MenuItem(
"Window/PIXO/Voiceover importer")]
25 public static void Open()
27 GetWindow(typeof(VoiceOverImporterWindow),
false,
"Voiceover importer");
34 var name = Path.GetFileNameWithoutExtension(filePath);
36 var voiceOverDataPath = $
"{VoiceOverDataPath}/{name}.asset";
37 var asset = AssetDatabase.LoadAssetAtPath<
VoiceOverData>(voiceOverDataPath);
41 Directory.CreateDirectory(voiceOverDataPath);
43 AssetDatabase.CreateAsset(asset, voiceOverDataPath);
46 for (
int i = 0; i < sheet.Count; i++)
48 string id = sheet[i][0];
49 string text = sheet[i][1];
51 if (!asset.voiceOverInfos.Any(v => v.id ==
id))
56 var info = asset.voiceOverInfos.First(v => v.id ==
id);
57 info.voiceOverText = text;
59 string[] guids = AssetDatabase.FindAssets($
"t:AudioClip {id}",
new[] {$
"{VoiceOverDataPath}/Clips"});
61 AudioClip clip =
null;
63 foreach (
string guid
in guids)
65 var fileName = Path.GetFileNameWithoutExtension(AssetDatabase.GUIDToAssetPath(guid));
69 clip = AssetDatabase.LoadAssetAtPath<AudioClip>(AssetDatabase.GUIDToAssetPath(guid));
75 info.voiceOver = clip;
79 Debug.LogWarning(
"No audio clip for " +
id);
83 EditorUtility.SetDirty(asset);
Data that stores all information about voice overs.
static List< List< string > > LoadFromPath(string path, Delimiter delimiter=Delimiter.Auto, Encoding encoding=null)
Load CSV data from specified path.