//画小地图自动寻路路径 zjw public void DrawMapImage(NavMeshPath path) { if (plane != null) { Desmapimg(); } else { mapimg = GAMEAPI.ABUI_LoadPrefab("map_icon_scene_mappath"); plane = GameObject.CreatePrimitive(PrimitiveType.Plane); plane.name = "NmaImageList"; plane.transform.SetParent(transform.Find("mapcon").transform); plane.transform.localPosition = Vector3.zero; plane.transform.localScale = new Vector3(1, 1, 1); plane.transform.SetSiblingIndex(transform.Find("mapcon/p").transform.GetSiblingIndex()); } mapImgPath.Clear(); // mapImgpb.Clear(); //计算生成坐标 for (int p = 0; p < path.corners.Length; p++) { if (p != path.corners.Length - 1) { var AllWayp = Vector3.Distance(path.corners[p + 1], path.corners[p]); if (AllWayp > 5f) { var AllNumde = (int)(AllWayp / 5); Vector3 AllWaypV3 = path.corners[p + 1] - path.corners[p]; Vector3 WaypV3 = AllWaypV3 / (AllNumde + 1); Vector3 pos = path.corners[p]; for (int num = 0; num < AllNumde; num++) { pos += WaypV3; mapImgPath.Add(SceneCamera.getPosOnMiniMapNMA(pos)); } mapImgPath.Add(SceneCamera.getPosOnMiniMapNMA(path.corners[p + 1])); } else if (AllWayp > 2f) { mapImgPath.Add(SceneCamera.getPosOnMiniMapNMA(path.corners[p + 1])); } } } for (int pos = 0; pos < mapImgPath.Count; pos++) { if (mapImgPath.Count > mapImgpb.Count) { for (int y = 0; y < (mapImgPath.Count - mapImgpb.Count); y++) { mapImgpb.Add(GameObject.Instantiate(mapimg) as GameObject); } } mapImgpb[pos].transform.SetParent(plane.transform); mapImgpb[pos].transform.localPosition = mapRotation * mapImgPath[pos]; } }