using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class CloneInstanceText : CloneSingleObj { public override void Awake() { ResourcesName = "Prefab/Tool/InstanceText"; cloneObjType = CloneObjType.InstanceText; base.Awake(); } public override void SetCloneGameObject(GameObject obj) { base.SetCloneGameObject(obj); obj.AddComponent(); } /// /// 添加初始状态记录 /// /// public override void AddRecordFrame(List list) { foreach (Transform child in transform) { var data = new RecordInstanceText(); SetBaseData(data, child); SetInstanceText(data, child); string json = JsonUtility.ToJson(data); var objectJson = new ObjectData(); objectJson.cloneObjType = cloneObjType; objectJson.json = json; list.Add(objectJson); } } /// /// 添加记录(克隆) /// public override void AddRecordEventClone(Transform obj) { 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.Clone; var data = new RecordInstanceText(); SetBaseData(data, obj); SetInstanceText(data, obj); string json = JsonUtility.ToJson(data); eventData.json = json; RecordManager.Instance.jsonData.eventDataList.Add(eventData); } } private void SetInstanceText(RecordInstanceText data, Transform child) { var textControl = child.GetComponent(); data.Color = textControl.Color; data.Scale = textControl.Scale; data.InputField = textControl.InputField; } }