将选中的物体写入XML文件
using System.Collections;
using System.Collections.Generic;
using System.Xml.Linq;
using UnityEditor;
using UnityEngine;
public class GenerateXMLInfoFile
{
[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("Name",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(rotation);
XElement scaleInfo = new XElement("Scale");
string scale = item.transform.localScale.x + "|" + item.transform.localScale.y + "|" + item.transform.localScale.z;
scaleInfo.SetValue(scale);
root.Add(objName);
objName.Add(posInfo);
objName.Add(rotInfo);
objName.Add(scaleInfo);
root.Save("G:\\234.xml");
}
}
}
}
将选中的物体写入XML文件的更多相关文章
- C#读取和写入XML文件
关于xml是属于一个比较重要的东西,在平时开发的过程中,这块内容最主要的是要掌握XML内容的读取和写入操作. 一.什么是XML? XML 指可扩展标记语言(EXtensible Markup Lang ...
- xml文件生成方式一(字符串拼接,将多实体类对象写入xml文件)
1.xml文件生成,拼接字符串使用StringBuffer或StringBuilder 2.拼接好后写入文件即可,将多个实体类写入xml文件 3.这种方式比较简单,但是操作也比较麻烦 4.下面是我的代 ...
- 通俗易懂,C#如何安全、高效地玩转任何种类的内存之Span的脾气秉性(二)。 异步委托 微信小程序支付证书及SSL证书使用 SqlServer无备份下误删数据恢复 把list集合的内容写入到Xml中,通过XmlDocument方式写入Xml文件中 通过XDocument方式把List写入Xml文件
通俗易懂,C#如何安全.高效地玩转任何种类的内存之Span的脾气秉性(二). 前言 读完上篇<通俗易懂,C#如何安全.高效地玩转任何种类的内存之Span的本质(一).>,相信大家对sp ...
- spring 多线程 写入数据库 和 写入 xml文件
最近工作中遇到一个需求 多线程先爬取页面 然后将爬取的结果持久化到数据库中 ,一些大文本的内容需要持久化到 xml文件中; 下面是运行后的结果: xml 文件写入结果: 数据库写入结果: 再来张项目结 ...
- 【python小练】0017-将xls文件内容写入xml文件中
第 0017 题: 将 第 0014 题中的 student.xls 文件中的内容写到 student.xml 文件中,如 下所示: <?xml version="1.0" ...
- C#Doc写入 XML文件
HTML是XML的先驱,XML延续了HTML的简单性的优点.XML不是用来替代HTML的, XML和HTML为不同的目的而设计: XML被设计用来描述数据,其焦点是数据的内容.HTML被设计用来显示数 ...
- 通过XDocument方式把List写入Xml文件
List<Person> list=new List<Person>{ new Person(){Name="张三",Age=50,Address=&quo ...
- 把list集合的内容写入到Xml中,通过XmlDocument方式写入Xml文件中
List<Person> list = new List<Person> { new Person{Name="张三",Age=20,Email=" ...
- org.dom4j.IllegalAddException: No such namespace prefix: *** is in scope on: org.dom4j.tree.DefaultElement (dom4j写入XML文件,标签中带【:】(冒号)解决办法)
用dom4j操作写XML文件,标签中含有冒号,会报 org.dom4j.IllegalAddException: No such namespace prefix: *** is in scope o ...
随机推荐
- phpredis扩展实现LBS距离计算和范围筛选
来源 public function geo(){ $redis = new \redis(); $redis -> connect('127.0.0.1',6379); //位置增加 $res ...
- 获取页面所有a标签href
for(i=0;i<=document.getElementsByTagName("a").length;i++){ console.log(document.getElem ...
- idea工具maven生命周期clean,compile,install,package区别
idea工具maven projects里面有9种生命周期,今天刚好遇到,顺便分享下自己的理解.生命周期是包含在一个项目构建中的一系列有序的阶段.最常用的两种打包方法:一:clean,package( ...
- 迭代和JDB(课下作业,选做)
迭代和JDB(课下作业,选做) 题目要求 1 使用C(n,m)=C(n-1,m-1)+C(n-1,m)公式进行递归编程实现求组合数C(m,n)的功能 2 m,n 要通过命令行传入 3 提交测试运行截图 ...
- js圆形头像实现
定义CSS <style> .to{width:100px;height:100px;border-radius:100px} </style> 这样就实现了 主要是borde ...
- Linux S和T权限
S (setuid) 场景: 像修改密码的流程其实就是通过 /usr/bin/passwd 命令对 /etc/passwd进行修改,我们需要修改自己的密码(就是修改/etc/shadow),然而普通用 ...
- linux安装lamp环境(linux+apache+mysql+php)
源码安装 本次使用 Centos7.2 MySQL5.7.22 Apache2.4.37 PHP5.6.38 安装Apache 安装httpd和所需依赖:gcc, apr, apr-util,apr- ...
- golang 关于 interface 的学习整理
Golang-interface(四 反射) go语言学习-reflect反射理解和简单使用 为什么在Go语言中要慎用interface{} golang将interface{}转换为struct g ...
- rsync拉取服务器上的代码到本地
#!/bin/sh ];then echo "The parameters must be input:file path and host" read -p "(Exa ...
- 一个二维码-->网址-->iOS/Android跳转
view-source:https://dpx.shopo.com.cn/down.html lmxmn117:~ will.wei$ curl https://dpx.shopo.com.cn/do ...