using AX.MessageSystem; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class ArrowScalePanel : MonoBehaviour { public static ArrowScalePanel Instance; public Slider slider; public ArrowSizeData data = new ArrowSizeData(); // Use this for initialization void Awake () { Instance = this; slider = transform.Find("Slider").GetComponent(); slider.onValueChanged.AddListener(SetSize); gameObject.SetActive(false); MessageDispatcher.AddListener("CANCEL_SELECTED_COMMAND", cancel); MessageDispatcher.AddListener("ReplayEvent", ExecuteEvent); MessageDispatcher.AddListener("SelectChange", selectchange); } private void ExecuteEvent(IMessage obj) { var item = (EventData)obj.Data; if (item.eventType == RecordEventType.ArrowSizeChange) { var data = JsonUtility.FromJson(item.json); MessageDispatcher.SendMessage("ArrowSizeChange", data); } } private void OnDestroy() { MessageDispatcher.RemoveListener("CANCEL_SELECTED_COMMAND", cancel); MessageDispatcher.RemoveListener("ReplayEvent", ExecuteEvent); MessageDispatcher.RemoveListener("SelectChange", selectchange); } private void selectchange(IMessage obj) { gameObject.SetActive(false); } private void cancel(IMessage obj) { gameObject.SetActive(false); data.id = -1; slider.value = 0; } public void OpenPanel(long id,float value) { data.id = id; slider.value = value; gameObject.SetActive(true); } void SetSize(float value) { data.value = value; MessageDispatcher.SendMessage("ArrowSizeChange", data); AddReplayChangeEvent(data); } private void AddReplayChangeEvent(ArrowSizeData data) { if (ReplaySetting.PlayStatus == PlayStatus.isEditor && RecordManager.Instance.recordStatus == RecordStatus.normal) { var eventData = new EventData(); eventData.time = RecordManager.Instance.RecordTimer; //eventData.cloneObjType = cloneObjType; eventData.eventType = RecordEventType.ArrowSizeChange; string json = JsonUtility.ToJson(data); eventData.json = json; RecordManager.Instance.jsonData.eventDataList.Add(eventData); } } } public class ArrowSizeData { public long id; public float value; }