<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Scale markers on smooth zoom]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=785&amp;type=atom" />
	<updated>2018-02-22T15:01:57Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=785</id>
		<entry>
			<title type="html"><![CDATA[Re: Scale markers on smooth zoom]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3430#p3430" />
			<content type="html"><![CDATA[<p>I managed to solve both of my problems ! Thanks a lot Alex <img src="https://forum.infinity-code.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></content>
			<author>
				<name><![CDATA[Sangrene]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=570</uri>
			</author>
			<updated>2018-02-22T15:01:57Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3430#p3430</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Scale markers on smooth zoom]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3427#p3427" />
			<content type="html"><![CDATA[<p>Yes, the video shows that the shift occurs at the end of the zoom.<br />This is the part of the code that I changed.</p><p>The problem did not appear on my devices, so I can not be 100% sure. <br />Only you know it helped or not.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2018-02-22T11:07:48Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3427#p3427</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Scale markers on smooth zoom]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3424#p3424" />
			<content type="html"><![CDATA[<p>Thanks Alex !</p><p>I was totally looking at another part of the code... The problem was when the 2nd finger was raised right ?<br />I&#039;ll try the 1st idea, it was my first thing to try <img src="https://forum.infinity-code.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>Still the best support among all the Unity assets !</p>]]></content>
			<author>
				<name><![CDATA[Sangrene]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=570</uri>
			</author>
			<updated>2018-02-22T01:54:44Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3424#p3424</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Scale markers on smooth zoom]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3421#p3421" />
			<content type="html"><![CDATA[<p>Thank you for the video. It really helped to understand what was happening.<br />Try to replace:<br /></p><div class="codebox"><pre><code>else
{
    if (smoothZoomStarted)
    {
        lastGestureDistance = 0;
        Vector2 center = new Vector2 (Screen.width / 2, Screen.height / 2);
        double ox, oy;
        if (transform.localScale.x &lt; 0.9)
        {
            ZoomOnPoint(1, center);
            transform.localScale *= 2;
        }
        if (GetCoords (out ox, out oy, center))
        {
            map.SetPosition (ox, oy);
            float scaleDifference = m_originalScale.x - transform.localScale.x;
            transform.localPosition = m_originalPosition + new Vector3 (map.tilesetSize.x / -2, 0, map.tilesetSize.y / 2) * scaleDifference;
        }
        ComputePinSizes (transform.localScale.x);
        needRestoreZoom = 3;
    }
    smoothZoomStarted = false;
}</code></pre></div><p>to:<br /></p><div class="codebox"><pre><code>else
{
    if (smoothZoomStarted)
    {
        lastGestureDistance = 0;
        needRestoreZoom = 3;
    }
    smoothZoomStarted = false;
}</code></pre></div><br /><p>We have at least two ways to scale the active marker:<br />1. In ComputePinSizes, check that the current marker is active, and multiply it scale by your ratio.<br />2. Keep the original marker.scale in marker.customData, and in ComputePinSizes multiply inverseScale by the value from marker.customData.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2018-02-21T21:13:00Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3421#p3421</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Scale markers on smooth zoom]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3417#p3417" />
			<content type="html"><![CDATA[<p>Hi Alex,</p><p>Thanks for this. Here is the link to the video when you can see the shift and the scale problem : </p><p><a href="https://drive.google.com/open?id=1ojOF3lOBHPrfjc9cn_F_kAUeFw1woFyU">https://drive.google.com/open?id=1ojOF3 … UeFw1woFyU</a></p><p>As you can see, when I click on a marker I scale it from 0.5 to 0.70, but by setting the markers scale to a constant value and not multiplying the previous scale I don&#039;t keep the last clicked marker on a higher scale than the others. I could store a click boolean in the marker tags and scale it accordingly but is there another cleaner way to achieve this ?</p><p>Thanks !</p>]]></content>
			<author>
				<name><![CDATA[Sangrene]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=570</uri>
			</author>
			<updated>2018-02-21T17:38:14Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3417#p3417</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Scale markers on smooth zoom]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3414#p3414" />
			<content type="html"><![CDATA[<p>Hello.</p><div class="codebox"><pre><code>private void ComputePinSizes (float scale)
{
    float inverseScale = 1 / scale;
    for (int i = 0; i &lt; OnlineMaps.instance.markers.Length; i++)
    {
        OnlineMaps.instance.markers[i].scale = inverseScale;
    }
    OnlineMaps.instance.Redraw();
}</code></pre></div><p>When I tested, I did not see a shift.<br />Please send the video what kind of shift you mean.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2018-02-20T00:57:42Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3414#p3414</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Scale markers on smooth zoom]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3409#p3409" />
			<content type="html"><![CDATA[<p>Hi everyone,</p><p>I recently added&nbsp; a custom tileset control script that Alex put in a precedent topic, which allows the zoom to be kind of smooth on mobile when using two fingers (just like the next verson will be with float zoom range). Unfortunately I can&#039;t manage to scale markers inversely to the zoom level and I would be glad if anyone share what function to use.</p><p>Here is my custom tileset control with the ComputePinSizes the function to scale markers, being called at every small zoom from the user.</p><p>EDIT : Also, I have a strange shift at the end of the zoom that I didn&#039;t manage to solve, it seems that it is not related to the code of my custom TilesetControl.</p>]]></content>
			<author>
				<name><![CDATA[Sangrene]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=570</uri>
			</author>
			<updated>2018-02-19T09:50:05Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3409#p3409</id>
		</entry>
</feed>
