RKZYLayer.cs 22 KB

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