public override void FromXML(XmlNodeList nodes)
    {
        Clear();
        foreach (XmlNode node in nodes)
        {
            CameraPathSpeed newCameraPathPoint = gameObject.AddComponent <CameraPathSpeed>();//CreateInstance<CameraPathSpeed>();
            newCameraPathPoint.hideFlags = HideFlags.HideInInspector;
            CameraPathPoint.PositionModes positionModes = (CameraPathPoint.PositionModes)Enum.Parse(typeof(CameraPathPoint.PositionModes), node["positionModes"].FirstChild.Value);
            switch (positionModes)
            {
            case CameraPathPoint.PositionModes.Free:
                CameraPathControlPoint cPointA = cameraPath[int.Parse(node["cpointA"].FirstChild.Value)];
                CameraPathControlPoint cPointB = cameraPath[int.Parse(node["cpointB"].FirstChild.Value)];
                float curvePercentage          = float.Parse(node["curvePercentage"].FirstChild.Value);
                AddPoint(newCameraPathPoint, cPointA, cPointB, curvePercentage);
                break;

            case CameraPathPoint.PositionModes.FixedToPoint:
                CameraPathControlPoint point = cameraPath[int.Parse(node["point"].FirstChild.Value)];
                AddPoint(newCameraPathPoint, point);
                break;
            }
            newCameraPathPoint.FromXML(node, cameraPath);
        }
    }
Ejemplo n.º 2
0
    //public override void FromXML(XmlNodeList nodes)
    //{
    //    Clear();
    //    foreach (XmlNode node in nodes)
    //    {
    //        CameraPathSpeed newCameraPathPoint = gameObject.AddComponent<CameraPathSpeed>();//CreateInstance<CameraPathSpeed>();
    //        newCameraPathPoint.hideFlags = HideFlags.HideInInspector;
    //        CameraPathPoint.PositionModes positionModes = (CameraPathPoint.PositionModes)Enum.Parse(typeof(CameraPathPoint.PositionModes), node["positionModes"].FirstChild.Value);
    //        switch (positionModes)
    //        {
    //            case CameraPathPoint.PositionModes.Free:
    //                CameraPathControlPoint cPointA = cameraPath[int.Parse(node["cpointA"].FirstChild.Value)];
    //                CameraPathControlPoint cPointB = cameraPath[int.Parse(node["cpointB"].FirstChild.Value)];
    //                float curvePercentage = float.Parse(node["curvePercentage"].FirstChild.Value);
    //                AddPoint(newCameraPathPoint, cPointA, cPointB, curvePercentage);
    //                break;

    //            case CameraPathPoint.PositionModes.FixedToPoint:
    //                CameraPathControlPoint point = cameraPath[int.Parse(node["point"].FirstChild.Value)];
    //                AddPoint(newCameraPathPoint, point);
    //                break;
    //        }
    //        newCameraPathPoint.FromXML(node, cameraPath);
    //    }
    //}

    public override void FromXML(XMLNodeList nodes)
    {
        if (nodes == null)
        {
            Debug.Log("not speed node");
            return;
        }
        Clear();
        foreach (XMLNode node in nodes)
        {
            CameraPathSpeed newCameraPathPoint = gameObject.AddComponent <CameraPathSpeed>();//CreateInstance<CameraPathSpeed>();
            newCameraPathPoint.hideFlags = HideFlags.HideInInspector;
            CameraPathPoint.PositionModes positionModes = (CameraPathPoint.PositionModes)Enum.Parse(typeof(CameraPathPoint.PositionModes), node.GetValue("positionModes>0>_text"));
            switch (positionModes)
            {
            case CameraPathPoint.PositionModes.Free:
                CameraPathControlPoint cPointA = cameraPath[int.Parse(node.GetValue("cpointA>0>_text"))];
                CameraPathControlPoint cPointB = cameraPath[int.Parse(node.GetValue("cpointB>0>_text"))];
                float curvePercentage          = float.Parse(node.GetValue("curvePercentage>0>_text"));
                AddPoint(newCameraPathPoint, cPointA, cPointB, curvePercentage);
                break;

            case CameraPathPoint.PositionModes.FixedToPoint:
                CameraPathControlPoint point = cameraPath[int.Parse(node.GetValue("point>0>_text"))];
                AddPoint(newCameraPathPoint, point);
                break;
            }
            newCameraPathPoint.FromXML(node, cameraPath);
        }
    }