VoiceIconWindow.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using wf;
  5. namespace SceneEditWindow
  6. {
  7. [AddComponentMenu("SceneEditWindow/VoiceIconWindow")]
  8. public class VoiceIconWindow : BasePhotoWindow
  9. {
  10. public override string windowName
  11. {
  12. get
  13. {
  14. return "VoiceIconWindow";
  15. }
  16. }
  17. public override void Awake()
  18. {
  19. VoiceIconData.Create();
  20. base.Awake();
  21. for (int i = 0; i < VoiceIconData.ItemData.EmotionTexFileNames.Length; i++)
  22. {
  23. UIWFTabButton uiwftabButton = this.CreateItemObject(this.itemGrit.gameObject, VoiceIconData.ItemData.EmotionTexFileNames[i]);
  24. uiwftabButton.name = i.ToString();
  25. EventDelegate.Add(uiwftabButton.onClick, delegate()
  26. {
  27. this.OnClickItem((VoiceIconData.ItemData.EmotionType)int.Parse(UIButton.current.name));
  28. });
  29. }
  30. this.pitchInput.onChangeValue.Add(new Action<float>(this.OnChangePitchValue));
  31. this.UpdateChildren();
  32. }
  33. public override void Start()
  34. {
  35. base.Start();
  36. this.pitchInput.value = (float)this.sceneEdit.maid.VoicePitch;
  37. }
  38. public void OnChangePitchValue(float value)
  39. {
  40. this.sceneEdit.maid.VoicePitch = (int)value;
  41. }
  42. protected virtual void OnDestroy()
  43. {
  44. foreach (KeyValuePair<string, Texture> keyValuePair in this.texDic)
  45. {
  46. UnityEngine.Object.DestroyImmediate(keyValuePair.Value);
  47. }
  48. this.texDic.Clear();
  49. }
  50. protected void OnClickItem(VoiceIconData.ItemData.EmotionType emotionType)
  51. {
  52. if (this.onClickVoiceEvent != null)
  53. {
  54. this.onClickVoiceEvent(emotionType);
  55. }
  56. }
  57. protected UIWFTabButton CreateItemObject(GameObject parent, string textFileName)
  58. {
  59. GameObject gameObject = Utility.CreatePrefab(parent, "SceneEdit/WindowParts/PoseIconItem", true);
  60. if (!this.texDic.ContainsKey(textFileName))
  61. {
  62. this.texDic.Add(textFileName, ImportCM.CreateTexture(textFileName));
  63. }
  64. UITexture component = gameObject.GetComponent<UITexture>();
  65. component.mainTexture = this.texDic[textFileName];
  66. return gameObject.GetComponent<UIWFTabButton>();
  67. }
  68. [SerializeField]
  69. public SceneEdit sceneEdit;
  70. [SerializeField]
  71. private UIGrid itemGrit;
  72. [SerializeField]
  73. private PhotoSliderAndInput pitchInput;
  74. public Action<VoiceIconData.ItemData.EmotionType> onClickVoiceEvent;
  75. private Dictionary<string, Texture> texDic = new Dictionary<string, Texture>();
  76. }
  77. }