using System; using System.Collections.Generic; using UnityEngine; using wf; namespace SceneEditWindow { [AddComponentMenu("SceneEditWindow/VoiceIconWindow")] public class VoiceIconWindow : BasePhotoWindow { public override string windowName { get { return "VoiceIconWindow"; } } public override void Awake() { VoiceIconData.Create(); base.Awake(); for (int i = 0; i < VoiceIconData.ItemData.EmotionTexFileNames.Length; i++) { UIWFTabButton uiwftabButton = this.CreateItemObject(this.itemGrit.gameObject, VoiceIconData.ItemData.EmotionTexFileNames[i]); uiwftabButton.name = i.ToString(); EventDelegate.Add(uiwftabButton.onClick, delegate() { this.OnClickItem((VoiceIconData.ItemData.EmotionType)int.Parse(UIButton.current.name)); }); } this.pitchInput.onChangeValue.Add(new Action(this.OnChangePitchValue)); this.UpdateChildren(); } public override void Start() { base.Start(); this.pitchInput.value = (float)this.sceneEdit.maid.VoicePitch; } public void OnChangePitchValue(float value) { this.sceneEdit.maid.VoicePitch = (int)value; } protected virtual void OnDestroy() { foreach (KeyValuePair keyValuePair in this.texDic) { UnityEngine.Object.DestroyImmediate(keyValuePair.Value); } this.texDic.Clear(); } protected void OnClickItem(VoiceIconData.ItemData.EmotionType emotionType) { if (this.onClickVoiceEvent != null) { this.onClickVoiceEvent(emotionType); } } protected UIWFTabButton CreateItemObject(GameObject parent, string textFileName) { GameObject gameObject = Utility.CreatePrefab(parent, "SceneEdit/WindowParts/PoseIconItem", true); if (!this.texDic.ContainsKey(textFileName)) { this.texDic.Add(textFileName, ImportCM.CreateTexture(textFileName)); } UITexture component = gameObject.GetComponent(); component.mainTexture = this.texDic[textFileName]; return gameObject.GetComponent(); } [SerializeField] public SceneEdit sceneEdit; [SerializeField] private UIGrid itemGrit; [SerializeField] private PhotoSliderAndInput pitchInput; public Action onClickVoiceEvent; private Dictionary texDic = new Dictionary(); } }