public void setChildgraphic(List<Vector3> pos) { creatmGraphic childGraphic=new creatmGraphic(); childGraphic.InitGraphic(childGraphic.getcenter(pos)); childGraphic.drawGraphic(pos); childGraphic._transParent.GetComponent<graphicMes>().setPointMes(pos); childGraphic.creatPoint (pos); childGraphic.creatLine (pos); }
public void pointTgraphic() { if (Input.GetMouseButtonDown (0) && graphicPoints.Count == 0) { Vector3 pos=Camera.main.ScreenToWorldPoint(Input.mousePosition); pos.z=10; pos=snapPoint(pos); graphicPoints.Add(pos); // creatmGraphic _graphic=new creatmGraphic(); // mGraphic=_graphic; // _graphic.InitGraphic(pos); // graphicTrans=_graphic._transParent.transform; graphicTrans=new GameObject("tempGraphic").transform; GameObject start=GameObject.Instantiate(pointPrefab); start.transform.position=pos; // start.name=_graphic._transName+"point0"; start.transform.parent=graphicTrans; clickCount=0; } if (Input.GetMouseButtonDown (0) && graphicPoints.Count>0&&clickCount>0){ Vector3 pos=Camera.main.ScreenToWorldPoint(Input.mousePosition); pos.z=10; pos=snapPoint(pos); if(graphicPoints[graphicPoints.Count-1]!=pos) { MLine line=new MLine(graphicPoints[graphicPoints.Count-1],pos,Color.black,graphicTrans); graphicPoints.Add(pos); GameObject point=GameObject.Instantiate(pointPrefab); point.transform.position=pos; // point.name=mGraphic._transName+"point"+clickCount.ToString(); point.transform.parent=graphicTrans; } if(graphicPoints[0]==pos) { // MLine line=new MLine(graphicPoints[graphicPoints.Count-1],pos,Color.black,graphicTrans); Destroy(GameObject.Find("tempGraphic")); mGraphic=new creatmGraphic(); mGraphic.InitGraphic(mGraphic.getcenter(graphicPoints)); mGraphic.drawGraphic(graphicPoints); mGraphic.creatLine(graphicPoints); mGraphic.creatPoint(graphicPoints); mGraphic._transParent.GetComponent<graphicMes>().setPointMes(graphicPoints); graphicPoints=new List<Vector3>(); //change state; state=Clickstate.oprateGraphic; } } clickCount++; }