using AX.MessageSystem; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class ReplaySetArea : ReplaySimpleObject { public GameObject PolygonPlane; public GameObject PolygonPlaneChild; public long GameobjID = 0; private void Awake() { GameObject PolygonPlane = GameObject.Find("Canvas/SetAreaPanel/PolygonPlaneBase").gameObject; GameObject PolygonPlaneChild = PolygonPlane.transform.Find("Plane").gameObject; } /// /// 回放克隆 /// /// public override void CloneObject(string json) { var jsonData = JsonUtility.FromJson(json); if (jsonData.isEvent) { ReplayEventClone(jsonData); } else { ReplayFrameDataClone(jsonData); } } private void ReplayFrameDataClone(RecordSetArea data) { GameObject PolygonPlane = GameObject.Find("Canvas/SetAreaPanel/PolygonPlaneBase").gameObject; GameObject PolygonPlaneChild = PolygonPlane.transform.Find("Plane").gameObject; PolygonPlaneChild.SetActive(true); var clonedObj = EntitiesManager.Instance.CreateObj(cloneBase.clonePrefab, data.myTransform.getMyPosition(), transform, long.Parse(data.objectName)); clonedObj.name = data.objectName;//名字即ID SetBaseGameObject(clonedObj, data); SetAreaData(clonedObj, data); SetCloneGameObject(clonedObj, ""); PolygonPlaneChild.SetActive(false); } private void ReplayEventClone(RecordSetArea data) { //PolygonPlaneChild.SetActive(true); var clonedObj = EntitiesManager.Instance.CreateObj(cloneBase.clonePrefab, data.myTransform.getMyPosition(), transform, long.Parse(data.objectName)); SetBaseGameObject(clonedObj, data); clonedObj.GetComponent().material.color = new Color(Color.yellow.r, Color.yellow.g, Color.yellow.b, 1f); clonedObj.GetComponent().PolyVerticeFather = GameObject.Find("Canvas/SetAreaPanel/PolyVerticeFather").GetComponent(); } private void SetAreaData(GameObject clonedObj, RecordSetArea jsonData) { var polyController = clonedObj.GetComponent(); for(int i = 0; i < jsonData.worldPositions.Count; i++) { polyController.ReplaySetPolygon(jsonData.worldPositions[i], jsonData.screenPositions[i]); } var areaController = clonedObj.GetComponent(); areaController.ReplayFrameData(jsonData); } public override void SetCloneGameObject(GameObject obj, string json) { obj.AddComponent(); obj.AddComponent(); } }