123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- 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;
- SubtitleDisplayManager component2 = gameObject.GetComponent<SubtitleDisplayManager>();
- component2.charaNameText = backlogUnit.m_speakerName;
- component2.originalText = backlogUnit.m_msg;
- component2.subtitlesText = backlogUnit.m_subtitlemsg;
- }
- }
- if (SubtitleDisplayManager.configDisplayType == SubtitleDisplayManager.DisplayType.OriginalAndSubtitle)
- {
- base.GetComponent<UIGrid>().cellHeight = 240f;
- }
- else
- {
- base.GetComponent<UIGrid>().cellHeight = 182f;
- }
- 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_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);
- }
- }
- }
|