I want to be able to, before a UXML is used, be able to read it’s contents as text, and spout out a new text content to be used instead.
I need this for my translation solution. Currently, it reads the XML, uses a regex to find anything enclosed in “$$”, and replaces it with it’s entry in the translation file
Example:
XML
<XmlLayout xmlns="XmlLayout"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="XmlLayout ../../../../../libs/Plugins/XmlLayout/XmlLayout/Configuration/XmlLayout.xsd">
<Defaults>
<Text class="SectionTitle" minHeight="40" color="rgb(1,1,1)" fontsize="20" font="Interface/Ubuntu-Medium"/>
<Text class="SectionTextRight" minHeight="23" alignment="UpperRight" color="rgb(0.5,0.5,0.5)" fontsize="16" font="Interface/Ubuntu-Medium"/>
<Text class="SectionTextLeft" minHeight="23" alignment="UpperLeft" color="rgb(0.5,0.5,0.5)" fontsize="16" font="Interface/Ubuntu-Medium"/>
</Defaults>
<VerticalLayout width="130" height="90">
<Text class="SectionTitle" width="130" height="40">$UIComposition$</Text>
<HorizontalLayout>
<VerticalLayout width="80" height="50" padding = "2,2,2,2">
<Override type="UnityEngine.UI.LayoutElement, UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" preferredWidth="0" flexibleWidth="99999"/>
<Text class="SectionTextRight" name="water">$UIWater$:</Text>
<Text class="SectionTextRight" name="fat">$UIFat$:</Text>
</VerticalLayout>
<VerticalLayout width="50" height="50" padding = "2,2,2,2">
<Override type="UnityEngine.UI.LayoutElement, UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" minWidth="55" preferredWidth="0" flexibleWidth="1"/>
<Text class="SectionTextLeft" name="waterValue">0</Text>
<Text class="SectionTextLeft" name="fatValue">0</Text>
</VerticalLayout>
</HorizontalLayout>
</VerticalLayout>
</XmlLayout>
If the selected language is english:
$$UIComposition$$
will be detected and changed to Composition
$$UIWater$$
will be detected and changed to Water
$$UIFat$$
will be detected and changed to Fat
only then, will the XML processor read the contents and make a hierarchy with it