<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Smoothly zoom to a zoomlevel when clicking a button ?]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1867&amp;type=atom" />
	<updated>2023-04-25T19:43:30Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=1867</id>
		<entry>
			<title type="html"><![CDATA[Re: Smoothly zoom to a zoomlevel when clicking a button ?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9004#p9004" />
			<content type="html"><![CDATA[<p>Yes, you&#039;re right, I missed that.<br />I updated the script in post #2/</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2023-04-25T19:43:30Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9004#p9004</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Smoothly zoom to a zoomlevel when clicking a button ?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9003#p9003" />
			<content type="html"><![CDATA[<p>Thank you Alex.</p><p>I also add the following to the button function and it works great:</p><p><strong>startZoom = OnlineMaps.instance.zoom; </strong></p><p>Thank you!</p>]]></content>
			<author>
				<name><![CDATA[savvas_6]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1113</uri>
			</author>
			<updated>2023-04-25T16:12:08Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9003#p9003</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Smoothly zoom to a zoomlevel when clicking a button ?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9002#p9002" />
			<content type="html"><![CDATA[<p>Hi.</p><p>Something like that:<br /></p><div class="codebox"><pre><code>using UnityEngine;

namespace InfinityCode.OnlineMapsSupport
{
    public class SmoothZoom : MonoBehaviour
    {
        public float duration = 1;
    
        private float progress = 1;
        private float targetZoom;
        private float startZoom;

        public void ZoomIn()
        {
            progress = 0;
            startZoom = OnlineMaps.instance.zoom;
            targetZoom = OnlineMaps.instance.zoom + 1;
        }
    
        public void ZoomOut()
        {
            progress = 0;
            startZoom = OnlineMaps.instance.zoom;
            targetZoom = OnlineMaps.instance.zoom - 1;
        }

        private void Update()
        {
            if (progress &gt;= 1) return;
        
            progress += Time.deltaTime / duration;
            if (progress &gt;= 1) progress = 1;
        
            float zoom = Mathf.Lerp(startZoom, targetZoom, progress);
            OnlineMaps.instance.floatZoom = zoom;
            OnlineMaps.instance.Redraw();
        }
    }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2023-04-24T18:42:59Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9002#p9002</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Smoothly zoom to a zoomlevel when clicking a button ?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9001#p9001" />
			<content type="html"><![CDATA[<p>Hi Alex, I want to add two buttons for zoom in and zoom out. What code should use to achieve a smooth zoom for each button?</p>]]></content>
			<author>
				<name><![CDATA[savvas_6]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1113</uri>
			</author>
			<updated>2023-04-24T17:58:19Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9001#p9001</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Smoothly zoom to a zoomlevel when clicking a button ?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7855#p7855" />
			<content type="html"><![CDATA[<p>Thanks,<br />We added a public bool everyFrame to this script.<br />It works fine !<br />Best regards.<br />Phil</p>]]></content>
			<author>
				<name><![CDATA[philzmz]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=606</uri>
			</author>
			<updated>2021-11-04T08:41:17Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7855#p7855</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Smoothly zoom to a zoomlevel when clicking a button ?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7851#p7851" />
			<content type="html"><![CDATA[<p>Hello.</p><p>Thanks for the bug report.<br />The problem has been fixed.<br />I have sent you the updated Playmaker Integration Kit by email.<br />The next version of the asset will contain this.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2021-11-03T00:50:23Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7851#p7851</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Smoothly zoom to a zoomlevel when clicking a button ?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7847#p7847" />
			<content type="html"><![CDATA[<p>Hello Alex</p><p>Something that I don&#039;t understand : the zoom in OnlineMaps.cs is an int. So I can&#039;t animate this value with a tween float for instance in Playmaker..</p><p>But it is possible to smooth the zoom on mouse event, and I would like to make this possible when I click a button.</p><p>I am wondering how I could make a Playmaker Script to be able to zoom smoothly on the map, instead of zooming by increments ?</p><p>I could do this with a simulated mouse clic, but this is not very effective, a dedicated action would be much better !</p><p>I mean action like &quot;on clic smoothly zoom to this zoomlevel&quot;</p><p>Best regards, Phil</p>]]></content>
			<author>
				<name><![CDATA[philzmz]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=606</uri>
			</author>
			<updated>2021-11-02T19:20:10Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7847#p7847</id>
		</entry>
</feed>
