using AX.MessageSystem; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; [Serializable] public class SmokeSettingData { public string name; public int value; } public class SmokePanel : ResourceLoadPanel { public Slider NongDu_Slider; public Button CloseBtn; private GameObject nowObj; private SmokeSettingData nowData; // Use this for initialization void Start() { CloseBtn.onClick.AddListener(CloseBtn_Click); NongDu_Slider.onValueChanged.AddListener(NongDu_SliderValueChanged); nowData = new SmokeSettingData(); MessageDispatcher.AddListener("SelectChange", selectchange); } private void OnDestroy() { MessageDispatcher.RemoveListener("SelectChange", selectchange); } private void selectchange(IMessage obj) { gameObject.SetActive(false); } private void NongDu_SliderValueChanged(float value) { if (nowObj != null) { nowData.name = nowObj.name; nowData.value = (int)value; AddRecordEventSmoke(nowObj, nowData); var main = nowObj.GetComponent().MySmokeMain; main.maxParticles = (int)(value * 10); } } public void AddRecordEventSmoke(GameObject obj, SmokeSettingData data) { if (ReplaySetting.PlayStatus == PlayStatus.isEditor && RecordManager.Instance.recordStatus == RecordStatus.normal) { var eventData = new EventData(); eventData.time = RecordManager.Instance.RecordTimer; eventData.cloneObjType = obj.GetComponent().gameObjType; if (eventData.cloneObjType == CloneObjType.SmokeNormal) { eventData.eventType = RecordEventType.SmokeNormal; } else if (eventData.cloneObjType == CloneObjType.SmokeInside) { eventData.eventType = RecordEventType.SmokeInside; } eventData.json = JsonUtility.ToJson(data); RecordManager.Instance.jsonData.eventDataList.Add(eventData); } } private void CloseBtn_Click() { gameObject.SetActive(false); nowObj = null; } public void SetNongDu(GameObject obj, int value) { nowObj = obj; NongDu_Slider.value = value; } }