using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class BacklogCtrl : MonoBehaviour { public void CreateBacklog(List dicBacklog, UnityEngine.Object backlogPrefab) { this.ClearExistBacklog(); if (dicBacklog != null) { foreach (BacklogCtrl.BacklogUnit backlogUnit in dicBacklog) { GameObject gameObject = UnityEngine.Object.Instantiate(backlogPrefab) as GameObject; GameObject childObject = UTY.GetChildObject(gameObject, "Voice", false); UIButton component = childObject.GetComponent(); if (backlogUnit.m_voiceId != string.Empty) { childObject.SetActive(true); EventDelegate.Add(component.onClick, new EventDelegate.Callback(this.ClickVoiceButton)); component.name = backlogUnit.m_voiceId; if (!string.IsNullOrEmpty(component.name)) { UIButton uibutton = component; uibutton.name = uibutton.name + "|" + backlogUnit.m_voicePitch; } } else { childObject.SetActive(false); } gameObject.transform.parent = base.transform; gameObject.transform.localScale = Vector3.one; gameObject.transform.localPosition = Vector3.zero; gameObject.transform.rotation = Quaternion.identity; UILabel component2 = UTY.GetChildObject(gameObject, "SpeakerName", false).GetComponent(); component2.text = backlogUnit.m_speakerName; UILabel component3 = UTY.GetChildObject(gameObject, "Message", false).GetComponent(); component3.text = backlogUnit.m_msg; } } base.GetComponent().Reposition(); } private void ClearExistBacklog() { IEnumerator enumerator = base.transform.GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; Transform transform = (Transform)obj; UnityEngine.Object.Destroy(transform.gameObject); } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } } private void ClickVoiceButton() { string name = UIButton.current.name; if (!string.IsNullOrEmpty(name)) { string[] array = name.Split(new char[] { '|' }); GameMain.Instance.SoundMgr.VoiceStopAll(); GameMain.Instance.SoundMgr.PlayDummyVoice(array[0], 0f, false, false, int.Parse(array[1])); } Debug.Log(string.Format("ボイスボタン ボイスID={0}がクリックされました。", name)); } public class BacklogUnit { public string m_speakerName { get; set; } public string m_msg { get; set; } public string m_subtitlemsg { get; set; } public string m_voiceId { get; set; } public int m_voicePitch { get; set; } public override string ToString() { return string.Format("BacklogUnit=[m_speakerName={1}, m_msg={2}, m_voiceId={3}]", this.m_speakerName, this.m_msg, this.m_voiceId); } } }