1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class BacklogCtrl : MonoBehaviour
- {
- public void CreateBacklog(List<BacklogCtrl.BacklogUnit> 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<UIButton>();
- 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<UILabel>();
- component2.text = backlogUnit.m_speakerName;
- UILabel component3 = UTY.GetChildObject(gameObject, "Message", false).GetComponent<UILabel>();
- component3.text = backlogUnit.m_msg;
- }
- }
- base.GetComponent<UIGrid>().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_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);
- }
- }
- }
|