<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — Customizing Line Style]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=462</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=462&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Customizing Line Style.]]></description>
		<lastBuildDate>Sun, 21 May 2017 17:55:19 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Customizing Line Style]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2387#p2387</link>
			<description><![CDATA[<p>Thank you very much, this works great!!</p>]]></description>
			<author><![CDATA[null@example.com (DaGround)]]></author>
			<pubDate>Sun, 21 May 2017 17:55:19 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2387#p2387</guid>
		</item>
		<item>
			<title><![CDATA[Re: Customizing Line Style]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2383#p2383</link>
			<description><![CDATA[<p>You can work around this in this way:<br /></p><div class="codebox"><pre><code>using System.Collections.Generic;
using System.Reflection;
using UnityEngine;

public class DrawLineWithTexture:MonoBehaviour
{
    public Texture2D lineTexture;
    private OnlineMapsMarker marker1;
    private OnlineMapsMarker marker2;
    private OnlineMapsDrawingLine line;

    private void Start()
    {
        OnlineMapsControlBase.instance.OnMapClick += OnMapClick;
    }

    private void OnMapClick()
    {
        OnlineMapsMarker marker = OnlineMaps.instance.AddMarker(OnlineMapsControlBase.instance.GetCoords());

        if (marker1 == null)
        {
            marker1 = marker;
            return;
        }

        marker2 = marker;
        List&lt;Vector2&gt; points = new List&lt;Vector2&gt;
        {
            marker1.position,
            marker2.position
        };
        line = new OnlineMapsDrawingLine(points, Color.red, 10);
        line.texture = lineTexture;
        OnlineMaps.instance.AddDrawingElement(line);
        OnlineMaps.instance.OnMapUpdated += OnMapUpdated; // Delay because the line is not yet drawn.

        marker1.OnDrag += OnMarkerDrag;
        marker2.OnDrag += OnMarkerDrag;
        OnlineMapsControlBase.instance.OnMapClick -= OnMapClick;
    }

    private void OnMapUpdated()
    {
        UpdateUVScale();
        OnlineMaps.instance.OnMapUpdated -= OnMapUpdated;
    }

    private void OnMarkerDrag(OnlineMapsMarkerBase marker)
    {
        List&lt;Vector2&gt; points = new List&lt;Vector2&gt;
        {
            marker1.position,
            marker2.position
        };
        line.points = points;

        UpdateUVScale();

        OnlineMaps.instance.Redraw();
    }

    private void UpdateUVScale()
    {
        FieldInfo field = line.GetType().GetField(&quot;gameObject&quot;, BindingFlags.NonPublic | BindingFlags.Instance);
        if (field == null)
        {
            Debug.Log(&quot;No field&quot;);
            return;
        }
        GameObject lineGO = field.GetValue(line) as GameObject;

        MeshFilter meshFilter = lineGO.GetComponent&lt;MeshFilter&gt;();
        Vector3[] vertices = meshFilter.sharedMesh.vertices;

        float distance = 0;

        for (int i = 2; i &lt; vertices.Length; i += 2) distance += (vertices[i - 2] - vertices[i]).magnitude;

        distance /= line.width * 2;

        MeshRenderer meshRenderer = lineGO.GetComponent&lt;MeshRenderer&gt;();
        meshRenderer.sharedMaterials[0].mainTextureScale = new Vector2(1, distance);
    }
}</code></pre></div><p>Yes, this is a bad practice and a dirty hack, but I do not know how to do this without access to the vertices.<br />Theoretically, we can make gameObject field public.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 19 May 2017 10:47:19 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2383#p2383</guid>
		</item>
		<item>
			<title><![CDATA[Re: Customizing Line Style]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2381#p2381</link>
			<description><![CDATA[<p>thanks for the answer, </p><p>i would like to stay with the intuitive DrawingLines, but just settings a texture doesnt help, it is getting scaled so unproportional with inreasing line length. Is there maybe a way to set a material with proper texture scaling for the lines?</p><p>please notice the image for the scaling issue</p><p><span class="postimg"><img src="https://picload.org/image/riricidi/scalings.jpg" alt="PunBB bbcode test" /></span></p>]]></description>
			<author><![CDATA[null@example.com (DaGround)]]></author>
			<pubDate>Thu, 18 May 2017 21:35:44 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2381#p2381</guid>
		</item>
		<item>
			<title><![CDATA[Re: Customizing Line Style]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2379#p2379</link>
			<description><![CDATA[<p>Hello</p><p>For example, in this way:<br /><a href="http://infinity-code.com/atlas/online-maps/pages/DottedLineExample.html">http://infinity-code.com/atlas/online-m … ample.html</a></p><p>Or using OnlineMapsDrawingLine.texture:<br /><a href="http://infinity-code.com/doxygen/online-maps/classOnlineMapsDrawingLine.html#a46bc9f411874a5e545a0764322fce7eb">http://infinity-code.com/doxygen/online … 4322fce7eb</a></p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Thu, 18 May 2017 19:46:09 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2379#p2379</guid>
		</item>
		<item>
			<title><![CDATA[Re: Customizing Line Style]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2376#p2376</link>
			<description><![CDATA[<p>When we cannot customize these Lines, do you have an suggestion how i could achieve this effekt?</p><p><span class="postimg"><img src="https://i.ytimg.com/vi/ozryKOSPTk4/maxresdefault.jpg" alt="PunBB bbcode test" /></span></p><br /><br /><p>im currently stuck with linedrawing on this, with a bunch of colors. </p><p><span class="postimg"><img src="https://picload.org/image/rircrgil/035c6bca-56ec-4cd6-b1df-b33560.jpg" alt="PunBB bbcode test" /></span></p><p>I at least need some kind of indicator in wich direction these lines are pointing .</p><p>Thank you!</p>]]></description>
			<author><![CDATA[null@example.com (DaGround)]]></author>
			<pubDate>Thu, 18 May 2017 11:27:03 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2376#p2376</guid>
		</item>
		<item>
			<title><![CDATA[Re: Customizing Line Style]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2034#p2034</link>
			<description><![CDATA[<p>Thx for your help.<br />I shoulld use tileset control with mainCamera~!</p>]]></description>
			<author><![CDATA[null@example.com (joonyboy)]]></author>
			<pubDate>Fri, 17 Mar 2017 01:02:32 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2034#p2034</guid>
		</item>
		<item>
			<title><![CDATA[Re: Customizing Line Style]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2026#p2026</link>
			<description><![CDATA[<p>Hello.</p><p>Unfortunately, there is no way to customize the line style.<br />To work around this, you can draw a line using NGUI (of course if NGUI supports this and you have programming experience).<br />Or you can use tileset control. This is supports textures for lines.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Thu, 16 Mar 2017 11:41:42 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2026#p2026</guid>
		</item>
		<item>
			<title><![CDATA[Customizing Line Style]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2024#p2024</link>
			<description><![CDATA[<p>I use AddDrawingElement function to draw the line on Map (NGUI Texture).</p><p>OnlineMaps.instance.AddDrawingElement(new OnlineMapsDrawingLine(list, Color.green, 3f));</p><p>But is there way to customizing the line style? (for example, using my own sprite image to draw line on Map)</p><p>I attached screen shot to help understand the situation.</p>]]></description>
			<author><![CDATA[null@example.com (joonyboy)]]></author>
			<pubDate>Thu, 16 Mar 2017 04:45:20 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2024#p2024</guid>
		</item>
	</channel>
</rss>
