コード例 #1
0
    public void LoadXML()
    {
        foreach (GameObject item in allObjects)
        {
            Destroy(item);
        }

        allObjects.Clear();

        ObjectInfoSaveLoad loadedClass = XMLDataSerialization.Read <ObjectInfoSaveLoad>(XmlfileName);

        SpawnWithData(loadedClass);
    }
コード例 #2
0
    public void SaveXML()
    {
        for (int i = 0; i < allObjects.Count; i++)
        {
            Transform current = allObjects[i].transform;

            ObjectInfo info = new ObjectInfo();
            info.SetPosition(current.position);
            info.SetRotation(current.eulerAngles);
            info.SetShapeId(int.Parse(current.name));
            info.SetColor(current.GetComponent <MeshRenderer>().material.color);
            info.SetVelocity(current.GetComponent <Rigidbody>().velocity);
            info.SetAngularVelocity(current.GetComponent <Rigidbody>().angularVelocity);

            objSaveLoad.AddInfo(info);
        }

        XMLDataSerialization.Write(XmlfileName, objSaveLoad);
    }