/// <summary> /// Generate and save a hexagon grid map. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSaveGrid_Click(object sender, EventArgs e) { sfdImage.ShowDialog(); if (sfdImage.FileName != String.Empty) { MapDraw draw = new MapDraw(); Image image = draw.DrawGrid(); image.Save(sfdImage.FileName); } }
static void SavePath() { //获取场景中全部道具 Object[] objects = Object.FindObjectsOfType(typeof(GameObject)); Dictionary <string, List <string> > post = new Dictionary <string, List <string> >(); foreach (GameObject sceneObject in objects) { if (sceneObject.name == mParentName) { MapDraw mapDraw = sceneObject.GetComponent <MapDraw>(); if (mapDraw == null) { Debug.LogError("MapDraw 脚本为null"); return; } foreach (Transform child in sceneObject.transform) { MapWayPoint editor = child.GetComponent <MapWayPoint>(); if (editor != null) { if (editor.pointList.Count <= 0) { Debug.LogError("The point child is null : " + child.transform.position); } List <string> childlist = new List <string>(); childlist.Add(editor.pointList.Count.ToString()); for (int i = 0; i < editor.pointList.Count; ++i) { childlist.Add(Util.GetPosString(editor.pointList[i].position)); } List <Vector3> path = mapDraw.pathDict[editor.name]; for (int i = 0; i < path.Count; ++i) { childlist.Add(Util.GetPosString(path[i])); } post.Add(editor.name, childlist); } } } } //保存文件 string filePath = Util.GetDataFilePath(mapname + ".text"); byte[] byteArray = System.Text.Encoding.Default.GetBytes(JsonMapper.ToJson(post)); Util.WriteByteToFile(byteArray, filePath); AssetDatabase.Refresh(); Debug.Log(JsonMapper.ToJson(post)); }
public void paintDrawingHandler(object sender, PaintEventArgs e) { MapDraw md = new MapDraw(); md.PaintDrawing(e.Graphics); }