<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — iOS Drawing API]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=2293&amp;type=atom" />
	<updated>2024-07-26T13:26:04Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=2293</id>
		<entry>
			<title type="html"><![CDATA[Re: iOS Drawing API]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9595#p9595" />
			<content type="html"><![CDATA[<p>That was the problem! Thank you!!<br />I use the below code in Start() and set CultureInfo.InvariantCulture instead changing every ToString and Parse.<br />Works great in the device now.</p><div class="codebox"><pre><code>void Start() {

       Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[savvas_6]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1113</uri>
			</author>
			<updated>2024-07-26T13:26:04Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9595#p9595</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: iOS Drawing API]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9594#p9594" />
			<content type="html"><![CDATA[<p>Hi.</p><p>I think you have a problem with CultureInfo and not with the Drawing API.</p><p>What I mean is:<br />Depending on the country, the integer and fractional parts of a number can be separated by a dot or comma.<br />This means that the code (10.99).ToString() can return &quot;10.99&quot; and &quot;10,99&quot;.<br />If you have the second case, you will get an invalid string when you use a comma-separated Join.</p><p>The best way to solve the problem is to use CultureInfo.InvariantCulture in ToString and Parse methods.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2024-07-25T20:15:55Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9594#p9594</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[iOS Drawing API]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9593#p9593" />
			<content type="html"><![CDATA[<p>Hi, <br />I came across an issue while loading Shapes on iOS device using the Drawing API. </p><p>In Unity Editor I save and load Shapes without any issue.</p><p>On iOS device when loading shapes I get vertical lines from North to South poles of the earth.<br />I attach an image to see the issue on the device.</p><p>Below is my code for loading and saving shapes:</p><div class="codebox"><pre><code>// Function to load shapes from PlayerPrefs
    public void LoadShapes()
    {
        if (!PlayerPrefs.HasKey(&quot;Shapes&quot;)) return;

        string xmlContent = PlayerPrefs.GetString(&quot;Shapes&quot;);
        OnlineMapsXML xml = OnlineMapsXML.Load(xmlContent);

        if (xml != null) {

            foreach (OnlineMapsXML shapeNode in xml)
            {
                if (shapeNode.name == &quot;Line&quot;) {

                    string pointsStr = shapeNode.Get&lt;string&gt;(&quot;Points&quot;);
                    //Debug.Log(pointsStr);

                    pointsStr = pointsStr.Replace(&quot;[&quot;, &quot;&quot;);
                    pointsStr = pointsStr.Replace(&quot;]&quot;, &quot;&quot;);
                    
                    string[] pointsArray = pointsStr.Split(&quot;,&quot;);
                   
                    List&lt;OnlineMapsVector2d&gt; points = new List&lt;OnlineMapsVector2d&gt;();
                    for (int i = 0; i &lt; pointsArray.Length-1; i += 2)
                    {
                       
                        double x = double.Parse(pointsArray[i]);
                        double y = double.Parse(pointsArray[i + 1]);
                        points.Add(new OnlineMapsVector2d(x, y));
                    }

                    OnlineMapsDrawingLine shape = new OnlineMapsDrawingLine(points);

                    shape.name = shapeNode.Get&lt;string&gt;(&quot;Name&quot;);
                    shape.color = shapeNode.Get&lt;Color&gt;(&quot;Color&quot;);
                    shape.width = shapeNode.Get&lt;float&gt;(&quot;Width&quot;);

                    OnlineMapsDrawingElementManager.AddItem(shape);

                    SavedLines.Add(shape);
                }

                if (shapeNode.name == &quot;Poly&quot;)
                {

                    string pointsStr = shapeNode.Get&lt;string&gt;(&quot;Points&quot;);
                   // Debug.Log(pointsStr);

                    pointsStr = pointsStr.Replace(&quot;]&quot;, &quot;&quot;);
                    pointsStr = pointsStr.Replace(&quot;[&quot;, &quot;&quot;);

                    string[] pointsArray = pointsStr.Split(&quot;,&quot;);

                    List&lt;OnlineMapsVector2d&gt; points = new List&lt;OnlineMapsVector2d&gt;();
                    for (int i = 0; i &lt; pointsArray.Length; i += 2)
                    {
                        double x = double.Parse(pointsArray[i]);
                        double y = double.Parse(pointsArray[i + 1]);
                        points.Add(new OnlineMapsVector2d(x, y));
                    }

                    OnlineMapsDrawingPoly shape = new OnlineMapsDrawingPoly(points);

                    shape.name = shapeNode.Get&lt;string&gt;(&quot;Name&quot;);
                    shape.borderColor = shapeNode.Get&lt;Color&gt;(&quot;Color&quot;);
                    shape.borderWidth = shapeNode.Get&lt;float&gt;(&quot;Width&quot;);

                    OnlineMapsDrawingElementManager.AddItem(shape);

                    SavedPolys.Add(shape);
                }

                if (shapeNode.name == &quot;Rect&quot;)
                {
                    string tmp9 = shapeNode.Get&lt;string&gt;(&quot;BottomLeft&quot;);
                    string tmp8 = shapeNode.Get&lt;string&gt;(&quot;TopRight&quot;);

                    

                    tmp9 = tmp9.Replace(&quot;&gt;&lt;&quot;, &quot;,&quot;);
                    tmp9 = tmp9.Replace(&quot;&gt;&quot;, &quot;&quot;);
                    tmp9 = tmp9.Replace(&quot;&lt;&quot;, &quot;&quot;);
                    tmp9 = tmp9.Replace(&quot;X&quot;, &quot;&quot;);
                    tmp9 = tmp9.Replace(&quot;Y&quot;, &quot;&quot;);
                    tmp9 = tmp9.Replace(&quot;/&quot;, &quot;&quot;);

                    tmp8 = tmp8.Replace(&quot;&gt;&lt;&quot;, &quot;,&quot;);
                    tmp8 = tmp8.Replace(&quot;&gt;&quot;, &quot;&quot;);
                    tmp8 = tmp8.Replace(&quot;&lt;&quot;, &quot;&quot;);
                    tmp8 = tmp8.Replace(&quot;X&quot;, &quot;&quot;);
                    tmp8 = tmp8.Replace(&quot;Y&quot;, &quot;&quot;);
                    tmp8 = tmp8.Replace(&quot;/&quot;, &quot;&quot;);

                    string[] pointsArrayBotLeft = tmp9.Split(&quot;,&quot;);
                    string[] pointsArrayTopRight = tmp8.Split(&quot;,&quot;);

                    OnlineMapsVector2d botLeft = new OnlineMapsVector2d(double.Parse(pointsArrayBotLeft[0]), double.Parse(pointsArrayBotLeft[1]));
                    OnlineMapsVector2d TopRight = new OnlineMapsVector2d(double.Parse(pointsArrayTopRight[0]), double.Parse(pointsArrayTopRight[1]));

                    OnlineMapsDrawingRect shape = new OnlineMapsDrawingRect(Vector2.zero, Vector2.zero);

                    shape.name = shapeNode.Get&lt;string&gt;(&quot;Name&quot;);

                    string l = shapeNode.Get&lt;string&gt;(&quot;Color&quot;);
                    string l2 = shapeNode.Get&lt;string&gt;(&quot;BackgroundColor&quot;);

                    l = l.Replace(&quot;)&quot;, &quot;&quot;);
                    l = l.Replace(&quot;RGBA(&quot;, &quot;&quot;);

                    l2 = l2.Replace(&quot;)&quot;, &quot;&quot;);
                    l2 = l2.Replace(&quot;RGBA(&quot;, &quot;&quot;);

                    string[] rgba = l.Split(&quot;,&quot;);
                    Color color1 = new Color(float.Parse(rgba[0]), float.Parse(rgba[1]), float.Parse(rgba[2]), float.Parse(rgba[3]));

                    string[] rgba2 = l2.Split(&quot;,&quot;);
                    Color color2 = new Color(float.Parse(rgba2[0]), float.Parse(rgba2[1]), float.Parse(rgba2[2]), float.Parse(rgba2[3]));

                    shape.borderColor = color1;
                    shape.backgroundColor = color2; //shapeNode.Get&lt;Color&gt;(&quot;BackgroundColor&quot;);

                    shape.borderWidth = shapeNode.Get&lt;float&gt;(&quot;Width&quot;);
                   
                    shape.bottomLeft = botLeft;
                    shape.topRight = TopRight;

                    OnlineMapsDrawingElementManager.AddItem(shape);

                    SavedRects.Add(shape);
                }

            }

            OnlineMaps.instance.Redraw();

            // Build Shape List
            CreateIndexingPagesPinakasShapes();
        }
    }


    public void SaveShapes()
    {
        OnlineMapsXML xml = new OnlineMapsXML(&quot;Shapes&quot;);

        // Lines
        foreach (OnlineMapsDrawingLine shape in SavedLines)
        {
            OnlineMapsXML shapeNode = xml.Create(&quot;Line&quot;);

            shapeNode.Create(&quot;Name&quot;, shape.name);
            shapeNode.Create(&quot;Color&quot;, shape.color);
            shapeNode.Create(&quot;Width&quot;, shape.width);

            List&lt;string&gt; points = new List&lt;string&gt;();

            foreach (OnlineMapsVector2d r in shape.points)
            {
                points.Add(r.ToString());
            }
          
            shapeNode.Create(&quot;Points&quot;, string.Join(&quot;,&quot;, points));
        }

        // Polygons
        foreach (OnlineMapsDrawingPoly shape in SavedPolys)
        {
            OnlineMapsXML shapeNode = xml.Create(&quot;Poly&quot;);

            shapeNode.Create(&quot;Name&quot;, shape.name);
            shapeNode.Create(&quot;Color&quot;, shape.borderColor);
            shapeNode.Create(&quot;Width&quot;, shape.borderWidth);

            List&lt;string&gt; points = new List&lt;string&gt;();

            foreach (OnlineMapsVector2d r in shape.points)
            {
                points.Add(r.ToString());
            }

            shapeNode.Create(&quot;Points&quot;, string.Join(&quot;,&quot;, points));
        }

        // Rectangles
        foreach (OnlineMapsDrawingRect shape in SavedRects)
        {
            OnlineMapsXML shapeNode = xml.Create(&quot;Rect&quot;);

            shapeNode.Create(&quot;Name&quot;, shape.name);
            shapeNode.Create(&quot;Color&quot;, shape.borderColor.ToString());
            shapeNode.Create(&quot;Width&quot;, shape.borderWidth);
            shapeNode.Create(&quot;BackgroundColor&quot;, shape.backgroundColor.ToString());

            //Debug.Log(shape.backgroundColor.ToString());

            shapeNode.Create(&quot;BottomLeft&quot;, shape.bottomLeft);
            shapeNode.Create(&quot;TopRight&quot;, shape.topRight);
        }

        PlayerPrefs.SetString(&quot;Shapes&quot;, xml.outerXml);
        PlayerPrefs.Save();

        // Build Shapes List
        CreateIndexingPagesPinakasShapes();

    }</code></pre></div>]]></content>
			<author>
				<name><![CDATA[savvas_6]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1113</uri>
			</author>
			<updated>2024-07-25T19:28:18Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9593#p9593</id>
		</entry>
</feed>
