// process click event private void PlacePointClickRecieved(EventParam positionParam) { if (clickCount == 0) { angleInstance = new PointsAngleClass(); instanceList.Add(angleInstance); } if (clickCount < 3) { clonePoint = Instantiate(refPoint, cloneParent); clonePoint.SetActive(true); clonePoint.transform.position = positionParam.getPointParam(); angleInstance.AddElement(clonePoint); anglePositions[clickCount] = clonePoint.transform.localPosition; clickCount += 1; } if (clickCount == 3) { angleLine = Instantiate(refLine, cloneParent); angleLine.SetActive(true); angleLine.name = "newLine"; angleLine.GetComponent <LineRenderer>().positionCount = 3; angleLine.GetComponent <LineRenderer>().SetPositions(anglePositions); angleInstance.AddLine(angleLine); } }
// restore saved measures method private void Restore(EventParam jsonStringParam) { // create an new measure instance from the JSON string angleInstance = JsonUtility.FromJson <PointsAngleClass>(jsonStringParam.getStringParam()); instanceList.Add(angleInstance); // instantiate enough point to render the measure List <GameObject> pointsList = new List <GameObject>(); for (int i = 0; i < 3; i++) { clonePoint = Instantiate(refPoint, cloneParent); pointsList.Add(clonePoint); } // instantiate a new line for the angle measure angleLine = Instantiate(refLine, cloneParent); // set the non serializable fields of the measure instance angleInstance.RestoreInstance(pointsList, angleLine); }