RKZYLayer.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. using Best.HTTP.Shared.Compression.Zlib;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using System;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using System.Text.RegularExpressions;
  8. using System.Threading.Tasks;
  9. using Unity.VisualScripting;
  10. using UnityAsync;
  11. using UnityEngine;
  12. using UnityEngine.Networking;
  13. using UnityEngine.UI;
  14. [System.Serializable]
  15. public class MovePlan
  16. {
  17. public string startPos;
  18. public string endPos;
  19. public int humanNum;
  20. public string time;
  21. }
  22. [System.Serializable]
  23. public class MoveAtten
  24. {
  25. public string title;
  26. public string pos;
  27. public string time;
  28. }
  29. [System.Serializable]
  30. public class ServerMovePlan {
  31. public bool isAfter;
  32. public bool isOut;
  33. public string desc;
  34. public string from;
  35. public float fromLong;
  36. public float fromLttd;
  37. public string to;
  38. public float toLong;
  39. public float toLttd;
  40. public int manNum;
  41. public int homeNum;
  42. public int completeNum;
  43. public string dateTime;
  44. public int villageCount;
  45. public int materialPrize;
  46. }
  47. [System.Serializable]
  48. public class ZYYAData
  49. {
  50. public int totalRoadCount;
  51. public float totalmanNum;
  52. public int totalVillageCount;
  53. public float totalMaterialPrize;
  54. }
  55. public class RKZYLayer : YZTRootLayer
  56. {
  57. public Text timeText;
  58. public LineInfo lineInfo;
  59. //public List<MovePlan> movePlans;
  60. public List<Thing1> movePlans;
  61. public List<MoveAtten> moveAttens;
  62. public static LineInfo lineInfoStatic;
  63. public Button beforeBtn;
  64. public Button afterBtn;
  65. public Button[] allInOut;
  66. public RectTransform beforeC;
  67. public RectTransform afterC;
  68. public List<LinePath> linePaths = new List<LinePath>();
  69. public Sprite[] sprites;
  70. public int inOutIndex;
  71. public int beforeAfterIndex;
  72. public RectTransform title1;
  73. public RectTransform plan1;
  74. public RectTransform movePlanBeforeContent;
  75. public RectTransform movePlanAfterContent;
  76. public RectTransform title2;
  77. public RectTransform plan2;
  78. public RectTransform attenContent;
  79. public List<ServerMovePlan> allServerMovePlans = new List<ServerMovePlan>();
  80. public Text[] zYGKText;
  81. public ZYYAData[] zYYADatas;
  82. public int zYYAIndex = 0;
  83. public Text[] zYYAText;
  84. public Material afterMat;
  85. public LinePath linePathPrefab;
  86. // Start is called before the first frame update
  87. async void Start()
  88. {
  89. lineInfoStatic = lineInfo;
  90. await InitMovePlan();
  91. //TODO 这一块的path应该从movePlan里面生成而不是默认
  92. InitAllPath();
  93. InitButton();
  94. InitAtten();
  95. await InitBaseData();
  96. }
  97. private void OnEnable()
  98. {
  99. CameraManager.SwitchCamera(1);
  100. }
  101. void InitAtten() {
  102. RectTransform title = Instantiate(title2);
  103. title.SetParent(attenContent);
  104. title.localScale = Vector3.one;
  105. for (int i = 0; i < moveAttens.Count; i++)
  106. {
  107. RectTransform plan = Instantiate(plan2);
  108. plan.SetParent(attenContent);
  109. plan.localScale = Vector3.one;
  110. plan.GetChild(0).GetComponent<Text>().text = i.ToString();
  111. plan.GetChild(1).GetComponent<Text>().text = moveAttens[i].title;
  112. plan.GetChild(2).GetComponent<Text>().text = moveAttens[i].pos;
  113. plan.GetChild(3).GetComponent<Text>().text = moveAttens[i].time;
  114. }
  115. }
  116. async Task InitBaseData() {
  117. bool successInternet = true;
  118. UnityWebRequest requestData = UnityWebRequest.Get(ServerAddress.APIGetGeBaseData);
  119. await requestData.SendWebRequest();
  120. try
  121. {
  122. if (requestData.result != UnityWebRequest.Result.Success)
  123. {
  124. Debug.LogWarning("RKZYLayer基础数据联网不成功,原因:返request不成功");
  125. successInternet = false;
  126. }
  127. else
  128. {
  129. JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
  130. JToken codeToken = jsonObject["code"];
  131. if (codeToken.ToString() == "200")
  132. {
  133. JToken areaToken = jsonObject["data"]["area"];
  134. JToken capacityToken = jsonObject["data"]["capacity"];
  135. JToken populationToken = jsonObject["data"]["population"];
  136. zYGKText[0].text = populationToken.ToString() + "人";
  137. zYGKText[1].text = allServerMovePlans.Count.ToString() + "条";
  138. zYGKText[2].text = areaToken.ToString() + "km²";
  139. zYGKText[3].text = (float.Parse((capacityToken.ToString())) * 100).ToString() + "%";
  140. }
  141. else
  142. {
  143. successInternet = false;
  144. Debug.LogWarning("RKZYLayer基础数据联网不成功,原因:返序列化失败");
  145. }
  146. }
  147. }
  148. catch (Exception e)
  149. {
  150. successInternet = false;
  151. Debug.LogWarning("RKZYLayer基础数据联网不成功,原因:" + e.ToString());
  152. }
  153. }
  154. async Task InitMovePlan() {
  155. bool successInternet = true;
  156. UnityWebRequest requestData = UnityWebRequest.Get(ServerAddress.APIGetGetMovePlans);
  157. await requestData.SendWebRequest();
  158. zYYADatas = new ZYYAData[6] { new ZYYAData(), new ZYYAData() , new ZYYAData() , new ZYYAData() , new ZYYAData() , new ZYYAData() };
  159. try
  160. {
  161. if (true)
  162. {
  163. Debug.LogWarning("RKZYLayer联网不成功,读本地缓存数据,原因:返request不成功");
  164. successInternet = false;
  165. }
  166. else
  167. {
  168. JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
  169. // 提取data字段的值
  170. JToken dataToken = jsonObject["data"];
  171. JToken codeToken = jsonObject["code"];
  172. if (codeToken.ToString() == "200")
  173. {
  174. allServerMovePlans = JsonConvert.DeserializeObject<List<ServerMovePlan>>(dataToken.ToString());
  175. }
  176. else
  177. {
  178. successInternet = false;
  179. Debug.LogWarning("XHGKLayer联网不成功,读本地缓存数据,原因:返序列化失败");
  180. }
  181. }
  182. }
  183. catch (Exception e)
  184. {
  185. successInternet = false;
  186. Debug.LogWarning("RKZYLayer联网不成功,读本地缓存数据,原因:" + e.ToString());
  187. }
  188. if (!successInternet)
  189. {
  190. WWW www = new WWW(Application.streamingAssetsPath + "/moveplan.json");
  191. await new UnityAsync.WaitUntil(() =>
  192. {
  193. return www.isDone;
  194. });
  195. allServerMovePlans = JsonConvert.DeserializeObject<List<ServerMovePlan>>(www.text);
  196. www.Dispose();
  197. }
  198. int beforeIndex = 0;
  199. int afterIndex = 0;
  200. List<LinePath> beforeLinePaths = new List<LinePath>();
  201. List<LinePath> afterLinePaths = new List<LinePath>();
  202. GameObject shaPan = GameObject.FindGameObjectWithTag("ShaPan");
  203. Transform runtimPointParent = shaPan.transform.GetChild(10);
  204. for (int i = 0; i < allServerMovePlans.Count; i++) {
  205. bool after = allServerMovePlans[i].isAfter;
  206. bool isOut = allServerMovePlans[i].isOut;
  207. if (!after)
  208. {
  209. LinePath linePath = Instantiate(linePathPrefab);
  210. linePath.transform.SetParent(beforeC);
  211. linePath.transform.localScale = Vector3.one;
  212. linePath.startPos = allServerMovePlans[i].from;
  213. Vector3 localPos = CoordinateConverter.GeoToUGUISmall(allServerMovePlans[i].fromLong, allServerMovePlans[i].fromLttd);
  214. Vector3 worldPos = runtimPointParent.TransformPoint(localPos);
  215. worldPos.z = -583;
  216. linePath.GetComponent<LineRenderer>().SetPosition(1, worldPos);
  217. linePath.endPos = allServerMovePlans[i].to;
  218. Vector3 localPos1 = CoordinateConverter.GeoToUGUISmall(allServerMovePlans[i].toLong, allServerMovePlans[i].toLttd);
  219. Vector3 worldPos1 = runtimPointParent.TransformPoint(localPos1);
  220. worldPos1.z = -583;
  221. float distance = Vector3.Distance(worldPos, worldPos1);
  222. linePath.GetComponent<LineRenderer>().material.SetTextureScale("_MainTex", new Vector2(distance * 120 / 25, 1));
  223. linePath.GetComponent<LineRenderer>().SetPosition(0, worldPos1);
  224. linePath.lineDir = isOut ? LineDir.Out : LineDir.In;
  225. linePath.linePathContent = allServerMovePlans[i].desc;
  226. linePath.manNum = allServerMovePlans[i].manNum;
  227. linePath.homeNum = allServerMovePlans[i].homeNum;
  228. linePath.completeNum = allServerMovePlans[i].completeNum;
  229. linePath.dateTime = allServerMovePlans[i].dateTime;
  230. if (linePath.lineDir == LineDir.Out)
  231. {
  232. zYYADatas[1].totalmanNum += allServerMovePlans[i].manNum;
  233. zYYADatas[1].totalVillageCount += allServerMovePlans[i].villageCount;
  234. zYYADatas[1].totalMaterialPrize += allServerMovePlans[i].materialPrize;
  235. zYYADatas[1].totalRoadCount += 1;
  236. }
  237. else
  238. {
  239. zYYADatas[2].totalmanNum += allServerMovePlans[i].manNum;
  240. zYYADatas[2].totalVillageCount += allServerMovePlans[i].villageCount;
  241. zYYADatas[2].totalMaterialPrize += allServerMovePlans[i].materialPrize;
  242. zYYADatas[2].totalRoadCount += 1;
  243. }
  244. beforeLinePaths.Add(linePath);
  245. }
  246. else
  247. {
  248. LinePath linePath = Instantiate(linePathPrefab);
  249. linePath.transform.SetParent(afterC);
  250. linePath.transform.localScale = Vector3.one;
  251. linePath.startPos = allServerMovePlans[i].from;
  252. Vector3 localPos = CoordinateConverter.GeoToUGUISmall(allServerMovePlans[i].fromLong, allServerMovePlans[i].fromLttd);
  253. Vector3 worldPos = runtimPointParent.TransformPoint(localPos);
  254. worldPos.z = -583;
  255. linePath.GetComponent<LineRenderer>().SetPosition(1, worldPos);
  256. linePath.endPos = allServerMovePlans[i].to;
  257. Vector3 localPos1 = CoordinateConverter.GeoToUGUISmall(allServerMovePlans[i].toLong, allServerMovePlans[i].toLttd);
  258. Vector3 worldPos1 = runtimPointParent.TransformPoint(localPos1);
  259. worldPos1.z = -583;
  260. float distance = Vector3.Distance(worldPos, worldPos1);
  261. linePath.GetComponent<LineRenderer>().material = afterMat;
  262. linePath.GetComponent<LineRenderer>().material.SetTextureScale("_MainTex", new Vector2(distance * 120 / 25,1));
  263. linePath.GetComponent<LineRenderer>().SetPosition(0, worldPos1);
  264. linePath.lineDir = isOut ? LineDir.Out : LineDir.In;
  265. linePath.linePathContent = allServerMovePlans[i].desc;
  266. linePath.manNum = allServerMovePlans[i].manNum;
  267. linePath.homeNum = allServerMovePlans[i].homeNum;
  268. linePath.completeNum = allServerMovePlans[i].completeNum;
  269. linePath.dateTime = allServerMovePlans[i].dateTime;
  270. if (linePath.lineDir == LineDir.Out)
  271. {
  272. zYYADatas[4].totalmanNum += allServerMovePlans[i].manNum;
  273. zYYADatas[4].totalVillageCount += allServerMovePlans[i].villageCount;
  274. zYYADatas[4].totalMaterialPrize += allServerMovePlans[i].materialPrize;
  275. zYYADatas[4].totalRoadCount += 1;
  276. }
  277. else
  278. {
  279. zYYADatas[5].totalmanNum += allServerMovePlans[i].manNum;
  280. zYYADatas[5].totalVillageCount += allServerMovePlans[i].villageCount;
  281. zYYADatas[5].totalMaterialPrize += allServerMovePlans[i].materialPrize;
  282. zYYADatas[5].totalRoadCount += 1;
  283. }
  284. afterLinePaths.Add(linePath);
  285. }
  286. zYYADatas[0].totalmanNum = zYYADatas[1].totalmanNum + zYYADatas[2].totalmanNum;
  287. zYYADatas[0].totalVillageCount = zYYADatas[1].totalVillageCount + zYYADatas[2].totalVillageCount;
  288. zYYADatas[0].totalMaterialPrize = zYYADatas[1].totalMaterialPrize + zYYADatas[2].totalMaterialPrize;
  289. zYYADatas[0].totalRoadCount = zYYADatas[1].totalRoadCount + zYYADatas[2].totalRoadCount;
  290. zYYADatas[3].totalmanNum = zYYADatas[4].totalmanNum + zYYADatas[5].totalmanNum;
  291. zYYADatas[3].totalVillageCount = zYYADatas[4].totalVillageCount + zYYADatas[5].totalVillageCount;
  292. zYYADatas[3].totalMaterialPrize = zYYADatas[4].totalMaterialPrize + zYYADatas[5].totalMaterialPrize;
  293. zYYADatas[3].totalRoadCount = zYYADatas[4].totalRoadCount + zYYADatas[5].totalRoadCount;
  294. RefreshZYYAData();
  295. }
  296. movePlans = new List<Thing1>();
  297. RectTransform title = Instantiate(title1);
  298. title.localScale = Vector3.one;
  299. title.SetParent(movePlanBeforeContent);
  300. RectTransform title2 = Instantiate(title1);
  301. title2.localScale = Vector3.one;
  302. title2.SetParent(movePlanAfterContent);
  303. List<ServerMovePlan> serverMovePlans = new List<ServerMovePlan>();
  304. for (int i = 0; i < beforeLinePaths.Count; i++)
  305. {
  306. int tempI = i;
  307. RectTransform plan = Instantiate(plan1);
  308. plan.SetParent(movePlanBeforeContent);
  309. Thing1 thing1 = plan.GetComponent<Thing1>();
  310. thing1.zyTime = ZYTime.Before;
  311. thing1.lineDir = beforeLinePaths[i].lineDir;
  312. thing1.bindLinePath = beforeLinePaths[i];
  313. thing1.GetComponent<Button>().onClick.AddListener(() =>
  314. {
  315. for (int i = 0; i < linePaths.Count; i++)
  316. {
  317. linePaths[i].gameObject.SetActive(false);
  318. }
  319. thing1.bindLinePath.gameObject.SetActive(true);
  320. });
  321. plan.localScale = Vector3.one;
  322. plan.GetChild(0).GetComponent<Text>().text = i.ToString();
  323. plan.GetChild(1).GetComponent<Text>().text = beforeLinePaths[i].startPos;
  324. plan.GetChild(2).GetComponent<Text>().text = beforeLinePaths[i].endPos;
  325. plan.GetChild(3).GetComponent<Text>().text = beforeLinePaths[i].manNum.ToString();
  326. plan.GetChild(4).GetComponent<Text>().text = beforeLinePaths[i].dateTime.ToString();
  327. movePlans.Add(thing1);
  328. }
  329. for (int i = 0; i < afterLinePaths.Count; i++)
  330. {
  331. RectTransform plan = Instantiate(plan1);
  332. plan.SetParent(movePlanAfterContent);
  333. Thing1 thing1 = plan.GetComponent<Thing1>();
  334. thing1.zyTime = ZYTime.After;
  335. thing1.lineDir = afterLinePaths[i].lineDir;
  336. thing1.bindLinePath = afterLinePaths[i];
  337. thing1.GetComponent<Button>().onClick.AddListener(() =>
  338. {
  339. for (int i = 0; i < linePaths.Count; i++)
  340. {
  341. linePaths[i].gameObject.SetActive(false);
  342. }
  343. thing1.bindLinePath.gameObject.SetActive(true);
  344. });
  345. plan.localScale = Vector3.one;
  346. plan.GetChild(0).GetComponent<Text>().text = i.ToString();
  347. plan.GetChild(1).GetComponent<Text>().text = afterLinePaths[i].startPos;
  348. plan.GetChild(2).GetComponent<Text>().text = afterLinePaths[i].endPos;
  349. plan.GetChild(3).GetComponent<Text>().text = afterLinePaths[i].manNum.ToString();
  350. plan.GetChild(4).GetComponent<Text>().text = afterLinePaths[i].dateTime.ToString();
  351. movePlans.Add(thing1);
  352. }
  353. movePlanAfterContent.gameObject.SetActive(false);
  354. }
  355. void ChangeLinePathChannel(int index) {
  356. switch (index)
  357. {
  358. case 0:
  359. for (int i = 0; i < linePaths.Count; i++)
  360. {
  361. linePaths[i].gameObject.SetActive(true);
  362. }
  363. break;
  364. case 1:
  365. for (int i = 0; i < linePaths.Count; i++)
  366. {
  367. if (linePaths[i].lineDir == LineDir.Out)
  368. linePaths[i].gameObject.SetActive(true);
  369. else
  370. linePaths[i].gameObject.SetActive(false);
  371. }
  372. break;
  373. case 2:
  374. for (int i = 0; i < linePaths.Count; i++)
  375. {
  376. if (linePaths[i].lineDir == LineDir.In)
  377. linePaths[i].gameObject.SetActive(true);
  378. else
  379. linePaths[i].gameObject.SetActive(false);
  380. }
  381. break;
  382. }
  383. }
  384. void RefreshZYYAData() {
  385. zYYAIndex = beforeAfterIndex * 3 + inOutIndex;
  386. zYYAText[0].text = zYYADatas[zYYAIndex].totalVillageCount.ToString();
  387. zYYAText[1].text = (zYYADatas[zYYAIndex].totalmanNum / 10000.0f).ToString("0.00");
  388. zYYAText[2].text = (zYYADatas[zYYAIndex].totalMaterialPrize / 100000000.0f).ToString("0.00");
  389. zYYAText[3].text = zYYADatas[zYYAIndex].totalRoadCount.ToString();
  390. }
  391. void InitButton() {
  392. beforeBtn.onClick.AddListener(() => {
  393. beforeAfterIndex = 0;
  394. beforeBtn.GetComponent<Image>().sprite = sprites[0];
  395. afterBtn.GetComponent<Image>().sprite = sprites[1];
  396. beforeC.gameObject.SetActive(true);
  397. afterC.gameObject.SetActive(false);
  398. movePlanBeforeContent.gameObject.SetActive(true);
  399. movePlanAfterContent.gameObject.SetActive(false);
  400. ChangeLinePathChannel(inOutIndex);
  401. RefreshZYYAData();
  402. });
  403. afterBtn.onClick.AddListener(() => {
  404. beforeAfterIndex = 1;
  405. beforeBtn.GetComponent<Image>().sprite = sprites[1];
  406. afterBtn.GetComponent<Image>().sprite = sprites[0];
  407. beforeC.gameObject.SetActive(false);
  408. afterC.gameObject.SetActive(true);
  409. movePlanBeforeContent.gameObject.SetActive(false);
  410. movePlanAfterContent.gameObject.SetActive(true);
  411. ChangeLinePathChannel(inOutIndex);
  412. RefreshZYYAData();
  413. });
  414. allInOut[0].onClick.AddListener(() =>
  415. {
  416. inOutIndex = 0;
  417. ChangeLinePathChannel(0);
  418. for (int i = 0; i < movePlans.Count; i++)
  419. {
  420. movePlans[i].gameObject.SetActive(true);
  421. }
  422. allInOut[0].gameObject.GetComponent<Image>().sprite = sprites[0];
  423. allInOut[1].gameObject.GetComponent<Image>().sprite = sprites[1];
  424. allInOut[2].gameObject.GetComponent<Image>().sprite = sprites[1];
  425. RefreshZYYAData();
  426. });
  427. allInOut[1].onClick.AddListener(() =>
  428. {
  429. inOutIndex = 1;
  430. ChangeLinePathChannel(1);
  431. for (int i = 0; i < movePlans.Count; i++)
  432. {
  433. if (movePlans[i].lineDir == LineDir.Out)
  434. movePlans[i].gameObject.SetActive(true);
  435. else
  436. movePlans[i].gameObject.SetActive(false);
  437. }
  438. allInOut[0].gameObject.GetComponent<Image>().sprite = sprites[1];
  439. allInOut[1].gameObject.GetComponent<Image>().sprite = sprites[0];
  440. allInOut[2].gameObject.GetComponent<Image>().sprite = sprites[1];
  441. RefreshZYYAData();
  442. });
  443. allInOut[2].onClick.AddListener(() =>
  444. {
  445. inOutIndex = 2;
  446. ChangeLinePathChannel(2);
  447. for (int i = 0; i < movePlans.Count; i++)
  448. {
  449. if (movePlans[i].lineDir == LineDir.In)
  450. movePlans[i].gameObject.SetActive(true);
  451. else
  452. movePlans[i].gameObject.SetActive(false);
  453. }
  454. allInOut[0].gameObject.GetComponent<Image>().sprite = sprites[1];
  455. allInOut[1].gameObject.GetComponent<Image>().sprite = sprites[1];
  456. allInOut[2].gameObject.GetComponent<Image>().sprite = sprites[0];
  457. RefreshZYYAData();
  458. });
  459. }
  460. void InitAllPath() {
  461. for (int i = 0; i < beforeC.childCount; i++)
  462. {
  463. if (beforeC.GetChild(i).GetComponent<LinePath>())
  464. {
  465. linePaths.Add(beforeC.GetChild(i).GetComponent<LinePath>());
  466. }
  467. }
  468. for (int i = 0; i < afterC.childCount; i++)
  469. {
  470. if (afterC.GetChild(i).GetComponent<LinePath>())
  471. {
  472. linePaths.Add(afterC.GetChild(i).GetComponent<LinePath>());
  473. }
  474. }
  475. }
  476. // Update is called once per frame
  477. void Update()
  478. {
  479. // 获取当前时间
  480. DateTime now = DateTime.Now;
  481. // 格式化时间字符串
  482. string timeString = now.ToString("yyyy/MM/dd HH:mm");
  483. // 将格式化的时间字符串设置到UI Text组件上
  484. timeText.text = timeString;
  485. }
  486. private void FixedUpdate()
  487. {
  488. if (lineInfo.linePaths.Count > 0)
  489. {
  490. lineInfo.gameObject.SetActive(true);
  491. }
  492. else
  493. {
  494. lineInfo.gameObject.SetActive(false);
  495. }
  496. Ray ray = CameraManager.instance.secondCamera.ScreenPointToRay(Input.mousePosition);
  497. RaycastHit hit;
  498. if (Physics.Raycast(ray, out hit, 10000))
  499. {
  500. Debug.Log(hit.collider.gameObject.name);
  501. // 检查射线是否击中 LineRenderer 所在的物体
  502. if (hit.collider.GetComponent<LineRenderer>() != null)
  503. {
  504. hit.collider.gameObject.GetComponent<LinePath>().OnShow();
  505. }
  506. }
  507. }
  508. }