using System.Collections;
using System.Collections.Generic;
using System.Xml.Linq;
using UnityEditor;
using UnityEngine;
public class D0513CreateAB
{
[MenuItem("UnityAB/CreateAB")]
public static void AnAB()
{
GameObject[] objs = Selection.gameObjects;
if (objs.Length > 0)
{
XDocument document = new XDocument();
XElement root = new XElement("Root");
foreach (var item in objs)
{
XElement objName = new XElement("GameObject");
objName.SetElementValue("oName", item.name);
XElement posInfo = new XElement("Postion");
string position = item.transform.position.x + "|" + item.transform.position.y + "|" + item.transform.position.z;
posInfo.SetValue(position);
XElement rotInfo = new XElement("Rotation");
string rotation = item.transform.localRotation.eulerAngles.x + "|" + item.transform.localRotation.eulerAngles.y + "|" + item.transform.localRotation.eulerAngles.x;
rotInfo.SetValue(position);
XElement scaleInfo = new XElement("Scale");
string scale = item.transform.localScale.x + "|" + item.transform.localScale.y + "|" + item.transform.localScale.z;
scaleInfo.SetValue(position);
root.Add(objName);
objName.Add(posInfo);
objName.Add(rotInfo);
objName.Add(scaleInfo);
root.Save("G:\\234.xml");
}
}
}
}
原文:https://www.cnblogs.com/MeowChocola/p/9033180.html