public static PBSpline CreateFromString(GameObject blockObj, string data) { if (string.IsNullOrEmpty(data) || blockObj.GetComponent <PBBlock>() == null) { return(null); } PBSpline spline = null; if (data.StartsWith("wire")) { spline = PBSplineWire.CreateNew(blockObj); } if (data.StartsWith("tube")) { spline = PBSplineTube.CreateNew(blockObj); } else if (data.StartsWith("track")) { spline = PBSplineTrack.CreateNew(blockObj); } if (spline != null) { spline.LoadString(data); } return(spline); }
public static PBSpline CreateNew(GameObject blockObj, string blockType) { switch (blockType) { case "wire": return(PBSplineWire.CreateNew(blockObj)); case "tube": return(PBSplineTube.CreateNew(blockObj)); case "track": return(PBSplineTrack.CreateNew(blockObj)); } return(null); }