Esempio n. 1
0
    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);
    }
Esempio n. 2
0
    public static string SaveToString(GameObject blockObj)
    {
        //必须是PBBlock
        if (blockObj.GetComponent <PBBlock>() == null)
        {
            return(null);
        }

        PBSpline pbspline = blockObj.GetComponentInChildren <PBSpline>(true);

        if (pbspline == null)
        {
            return(null);
        }

        return(pbspline.SaveString(FLOAT_STRING_FORMAT));
    }
Esempio n. 3
0
    public static bool BuildFromInfo(GameObject obj)
    {
        PBAnimNode pbNode = obj.GetComponent <PBAnimNode>();

        //1. spline
        if (pbNode.animNodeInfo.VersatileInfo.SplineInfo != null)
        {
            Renderer[] renderers = pbNode.GetComponentsInChildren <Renderer>();
            foreach (Renderer renderer in renderers)
            {
                renderer.enabled = true;
            }

            PBSpline.CreateFromString(pbNode.gameObject, pbNode.animNodeInfo.VersatileInfo.SplineInfo);
            return(true);
        }

        return(false);
    }
Esempio n. 4
0
    public static void SaveToXml(GameObject obj, XmlDocument xml, XmlElement parent)
    {
        //1. spline
        string splineStr = PBSpline.SaveToString(obj);

        if (!string.IsNullOrEmpty(splineStr))
        {
            XmlElement ele = xml.CreateElement("spline");
            ele.SetAttribute("data", splineStr);
            parent.AppendChild(ele);
        }

        //零件个数
        int blockCount = PBSpline.GetBlockCount(obj);

        if (blockCount > 1)
        {
            parent.SetAttribute("count", blockCount.ToString());
        }
    }