Documentation for the Unity C# Library
Loading...
Searching...
No Matches
VoiceOverData.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text.RegularExpressions;
5using Sirenix.OdinInspector;
6using UnityEngine;
7
8namespace PixoVR.Audio
9{
13 [CreateAssetMenu(menuName = "Scenarios Data Menu/Create VoiceOver Data", fileName = "VoiceOverData", order = 3)]
15 {
16 [SerializeField][Searchable] private List<VoiceOverInfo> _voiceOverInfos = new List<VoiceOverInfo>();
17
23 public AudioClip GetAudioClipVO(string voID)
24 {
25 var voiceOverInfo = _voiceOverInfos.SingleOrDefault(x => x.id == voID);
27 if (voiceOverInfo == null)
28 {
29 Debug.LogError("AudioClip GetAudioClipVO is NULL");
30
31 return null;
32 }
33
34 return voiceOverInfo.voiceOver;
35 }
36
42 public VoiceOverInfo GetDataVO(string voID)
43 {
44 VoiceOverInfo voiceOverInfo = _voiceOverInfos.SingleOrDefault(x => x.id == voID);
46 return voiceOverInfo;
47 }
48#if UNITY_EDITOR
49 public List<VoiceOverInfo> voiceOverInfos => _voiceOverInfos;
50
51 private void OnValidate()
52 {
53 Debug.Log($"VoiceoverData {name} validation begin");
54
55 for (int i = 0; i < _voiceOverInfos.Count; i++)
56 {
57 var v1 = _voiceOverInfos[i];
58
59 if (Regex.IsMatch(v1.id, @"\p{IsCyrillic}"))
60 {
61 Debug.LogError($"VoiceoverData {v1} Cyrillic symbol presented!!");
62 }
63
64 if (v1.voiceOver == null)
65 {
66 Debug.LogError($"VoiceoverData {v1.id} audioData not presented");
67 }
68
69 // if (v1.voiceOverText.Equals(String.Empty))
70 // {
71 // Debug.LogError($"VoiceoverData {v1} voiceOverText not presented");
72 // }
73
74 for (int j = i + 1; j < _voiceOverInfos.Count; j++)
75 {
76 var v2 = _voiceOverInfos[j];
77
78 if (v1.id.Equals(v2.id))
79 {
80 Debug.LogError($"VoiceoverData data {v1.id} duplicates at position {i}:{j}");
81 }
82 }
83 }
84
85 Debug.Log($"VoiceoverData {name} validation finish");
86 }
87#endif
88 }
89}
Data that stores all information about voice overs.
List< VoiceOverInfo > _voiceOverInfos
[SerializeField]
VoiceOverInfo GetDataVO(string voID)
Get voiceover info by id.
AudioClip GetAudioClipVO(string voID)
Get voiceover audio clip by id.
[System.Serializable]