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++; }
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 CreatServerObj(List<Vector3> graphiVertex,Vector3 graphicPos,Color _color) { creatmGraphic serverGraphic=new creatmGraphic(); serverGraphic.InitGraphic(graphicPos); serverGraphic.drawGraphic(graphiVertex); serverGraphic.creatLine(graphiVertex); serverGraphic.creatPoint(graphiVertex); serverGraphic._transParent.GetComponent<graphicMes>().setPointMes(graphiVertex); serverGraphic._transParent.transform.position = graphicPos; for(int i=0;i<serverGraphic._transParent.transform.childCount;i++) { if(serverGraphic._transParent.transform.GetChild(i).name=="plane") { serverGraphic._transParent.transform.GetChild(i).GetComponent<MeshRenderer>().material.color=_color; } } }