Game Development Reference
In-Depth Information
<?xml version="1.0"?>
<text>
<language id="english">
<text_entry id="text_01"><![CDATA[new
game]]></text_entry>
<text_entry id="text_02"><![CDATA[load
game]]></text_entry>
<text_entry id="text_03"><![CDATA[save
game]]></text_entry>
<text_entry id="text_04"><![CDATA[exit
game]]></text_entry>
</language>
<language id="yoda">
<text_entry id="text_01"><![CDATA[new game, you
start]]></text_entry>
<text_entry id="text_02"><![CDATA[load game, you
will]]></text_entry>
<text_entry id="text_03"><![CDATA[game save, you
have]]></text_entry>
<text_entry id="text_04"><![CDATA[leave now, you
must]]></text_entry>
</language>
</text>
Notice, the CDATA element encloses all custom text nodes to allow the
use of any characters and symbols. More information on CDATA can be
found online at http://www.w3schools.com/xml/xml_cdata.asp .
The XML defined earlier creates four text elements, one for each button on a sample
user interface menu. Each text element is assigned a unique ID: text_01 , text_02 ,
text_03 , and text_04 . These IDs uniquely identify each item of text in the game
and will match across all specified languages. The purpose here is to import the text
file into Unity that allows the developer to switch between languages at the touch
of a button, and have all relevant text elements in the game change automatically to
accommodate the language switch. Let's see how this works.
First import the localized text into a Resources folder in a Unity project. Create a
folder named Resources and then import the localized text file into it, as shown in
the following screenshot. In code, this means any object or class can load or open the
text file using a Resources.Load call, as we'll see soon.
 
Search WWH ::




Custom Search