海淀天下城电子沙盘单机版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.1 KiB

4 years ago
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<TextControl>();
}
/// <summary>
/// 添加初始状态记录
/// </summary>
/// <param name="list"></param>
public override void AddRecordFrame(List<ObjectData> 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);
}
}
/// <summary>
/// 添加记录(克隆)
/// </summary>
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<TextControl>();
data.Color = textControl.Color;
data.Scale = textControl.Scale;
data.InputField = textControl.InputField;
}
}