3using System.Runtime.Serialization;
13 internal string selectedSound;
14 internal bool triggerNextOnSoundEnd;
15 private bool deactivated;
16 private bool once =
true;
24 if (triggerNextOnSoundEnd) GetComponentInChildren<Toggle>().isOn =
true;
27 private void Player_SoundStopped(
object sender, EventArgs e)
48 private void FillDropdown()
51 var prefabBrowser = FindObjectOfType<pb_PrefabBrowser>();
52 var soundList = prefabBrowser.Sounds.transform.GetComponentsInChildren<Text>();
53 foreach (var o
in soundList)
selector.options.Add(
new Dropdown.OptionData(o.text));
56 if (!
string.IsNullOrEmpty(selectedSound))
57 for (var i = 0; i <
selector.options.Count; i++)
58 if (
selector.options[i].text == selectedSound)
71 if (
selector.options.Count < value + 1)
75 selectedSound =
selector.options[value].text;
77 var result =
new [] {
"/fileuploader/" + selectedSound};
78 var files = FindObjectsOfType<NAudioPlayer>(
true);
79 foreach (var file
in files)
81 if (
string.Equals(file.name, selectedSound, StringComparison.OrdinalIgnoreCase))
83 result[0] = file.filePath;
88 var result = Directory.GetFiles(Application.streamingAssetsPath,
selector.options[value].text,
89 SearchOption.AllDirectories);
91 if (result.Length == 1)
94 Debug.LogError(
"More than one sound file found with the same name! (or zero)");
110 if (
string.IsNullOrEmpty(
player.filePath))
112 var result = Directory.GetFiles(Application.streamingAssetsPath, selectedSound,
113 SearchOption.AllDirectories);
114 if (result.Length >= 1)
127 triggerNextOnSoundEnd = value;
138 public new void GetObjectData(SerializationInfo info, StreamingContext context)
140 base.GetObjectData(info, context);
141 info.AddValue(
"selectedSound", selectedSound, typeof(
string));
142 info.AddValue(
"triggerNextOnSoundEnd", triggerNextOnSoundEnd, typeof(
bool));
145 public SoundAction(SerializationInfo info, StreamingContext context) : base(info, context)
147 selectedSound = (string) info.GetValue(
"selectedSound", typeof(
string));
150 triggerNextOnSoundEnd = info.GetBoolean(
"triggerNextOnSoundEnd");
void TriggerOutput(string id)
List< GameObject > outPuts
void SetFilePath(string path)
EventHandler SoundStopped
SoundAction(SerializationInfo info, StreamingContext context)
override void Deactivate()
override void Triggered(string id)
new void GetObjectData(SerializationInfo info, StreamingContext context)
void OnToggleChanged(bool value)
void OnDropdownChanged(int value)