1.XML:
Parse XML files using open source scripting (JS language) in the Unity Community, URL: http://dev.grumpyferret.com/unity/, packaged xmlparser.unitypackage, saved in plugins\ In the Xmlparser directory. Network address: Http://pan.baidu.com/s/1i3hCd0L
How to use:
1 //Read XML2 voidReadXML ()3 {4M_enemylist =NewList<spawndata>();5 spawndata data;6 7Xmlparser Xmlparse =NewXmlparser ();8XMLNode node =Xmlparse. Parse (m_xmldata.text);9 TenXmlNodeList nodelist = node. Getnodelist ("root>0>table"); One for(inti =0; I < NodeList. Count; i++) A { -data =NewSpawndata (); -Data.wave =int. Parse (node. GetValue ("root>0>table>"+ i +"> @wave")); thedata.enemyname = node. GetValue ("root>0>table>"+ i +"> @enemyname"); -Data.level =int. Parse (node. GetValue ("root>0>table>"+ i +"> @level")); -Data.wait =float. Parse (node. GetValue ("root>0>table>"+ i +"> @wait")); - m_enemylist.add (data); + } -}
Not used. NET provides XML functionality because it makes the game more bulky, and unity does not recommend using it.
There is a file Mono.Xml.zip under the Unity4 installation directory Editor\data\documentation\html\en\uploads\main, which is a lite Xml parsing script (C # language) that is officially provided by unity.
The file is under the Unity5 installation directory Editor\data\documentation\en\uploads\main.
2.transform:
Using Transform directly in the script is equivalent to calling getcomponent<transform> (). If you need to use transform repeatedly in update (), you can mitigate performance consumption by declaring components and invoking references.
1 Public classMovecontrol:monobehaviour2 {3 Public floatMovespeed =10F;4 PrivateTransform thist;5 6 voidAwake ()7 {8Thist = This. Getcomponent<transform>();9 }Ten One voidUpdate () A { -Thist.translate (NewVector3 (Input.getaxis ("Horizontal"), Input.getaxis ("Vertical"),0) * Time.deltatime *movespeed); - } the}
"Code Optimization" Unity leaks the vacancy