| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace WildAttack
- {
- public class WayPointEditor : MonoBehaviour
- {
- private void Awake()
- {
- StartCoroutine(WayPointModule.GetInstance().LoadCSV("wayPoint.csv", () => { CreateWayPoint(); }));
- }
- // Start is called before the first frame update
- void Start()
- {
- //CreateWayPoint();
- }
- // Update is called once per frame
- void Update()
- {
- }
- public void CreateWayPoint()
- {
- // 读表get坐标
- Vector3[] ve3Arr = new Vector3[3];
- for (int i = 0; i < ve3Arr.Length; i++)
- {
- Vector2 ve2 = WayPointModule.GetInstance().GetDataByGroup(i + 1)[0].wayPoint[0];
- ve3Arr[i] = new Vector3(ve2.x, 35, ve2.y);
- }
- Dictionary<int, WayPointData> dataDic = WayPointModule.GetInstance().GetWayPointDic();
- for (int i = 0; i < dataDic.Count; i++)
- {
- Color color;
- if (dataDic[i + 1].spawnGroup == 1)
- {
- color = Color.red;
- }
- else if (dataDic[i + 1].spawnGroup == 2)
- {
- color = Color.blue;
- }
- else if (dataDic[i + 1].spawnGroup == 3)
- {
- color = Color.green;
- }
- else
- {
- color = Color.yellow;
- }
- for (int k = 0; k < dataDic[i + 1].wayPoint.Count; k++)
- {
- GameObject obj = Instantiate(Resources.Load<GameObject>("WayPoint"));
- obj.AddComponent<TestWay>().Init(i, k, dataDic[i + 1].wayPoint[k], color);
- }
- }
- // getY轴坐标
- //foreach (var item in wayPointObjs)
- //{
- // Ray ray = new Ray(item.transform.position, -item.transform.up);
- // RaycastHit hitInfo;
- // if (Physics.Raycast(ray, out hitInfo, 100, 1 << LayerMask.NameToLayer("Plane")))
- // {
- // if (hitInfo.collider.gameObject.layer == LayerMask.NameToLayer("Plane"))
- // {
- // item.transform.position = new Vector3(item.transform.position.x, hitInfo.point.y, item.transform.position.z);
- // }
- // }
- //}
- }
- }
- }
|