<?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 — Making tooltips shown after pressed until another marker is pressed.]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=301</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=301&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Making tooltips shown after pressed until another marker is pressed..]]></description>
		<lastBuildDate>Mon, 17 Oct 2016 14:14:01 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Making tooltips shown after pressed until another marker is pressed.]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1368#p1368</link>
			<description><![CDATA[<p>This is the default behavior of tooltips, but you can easily override this:<br /></p><div class="codebox"><pre><code>using System;
using UnityEngine;

public class ShowMarkersOnPressExample:MonoBehaviour
{
    private OnlineMapsMarkerBase activeMarker;
    private OnlineMaps map;
    private GUIStyle tooltipStyle;

    private void Start()
    {
        map = OnlineMaps.instance;
        map.showMarkerTooltip = OnlineMapsShowMarkerTooltip.onPress;

        // Add an event to the markers created by the inspector
        foreach (OnlineMapsMarker marker in map.markers) marker.OnPress += OnMarkerPress;

        // Add an event to a new dynamic marker
        map.AddMarker(map.position, &quot;Dynamic marker&quot;).OnPress += OnMarkerPress;

        // Subscribe to OnUpdateAfter
        OnlineMapsControlBase.instance.OnUpdateAfter += OnUpdateAfter;

        // Intercepts tooltip style.
        map.OnPrepareTooltipStyle += OnPrepareTooltipStyle;

        // Intercepts drawing tooltips.
        OnlineMapsMarkerBase.OnMarkerDrawTooltip += OnMarkerDrawTooltip;
    }

    private void OnPrepareTooltipStyle(ref GUIStyle style)
    {
        tooltipStyle = style;
    }

    private void OnMarkerDrawTooltip(OnlineMapsMarkerBase marker)
    {
        // Get screen position of marker
        Vector2 screenPosition = OnlineMapsControlBase.instance.GetScreenPosition(marker.position);

        // Calculate the size
        GUIContent tip = new GUIContent(marker.label);
        Vector2 size = tooltipStyle.CalcSize(tip);

        // Draw the tooltip
        GUI.Label(new Rect(screenPosition.x - size.x / 2 - 5, Screen.height - screenPosition.y - size.y - 20, size.x + 10, size.y + 5), marker.label, tooltipStyle);
    }

    /// &lt;summary&gt;
    /// This event occurs at end Update
    /// &lt;/summary&gt;
    private void OnUpdateAfter()
    {
        // If activeMarker exists, restore tootip
        if (activeMarker != null)
        {
            map.tooltipMarker = activeMarker;
            map.tooltip = activeMarker.label;
        }
    }

    /// &lt;summary&gt;
    /// This event occurs on marker press
    /// &lt;/summary&gt;
    /// &lt;param name=&quot;marker&quot;&gt;Instance of marker&lt;/param&gt;
    private void OnMarkerPress(OnlineMapsMarkerBase marker)
    {
        // Change active marker
        activeMarker = marker;
    }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Mon, 17 Oct 2016 14:14:01 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1368#p1368</guid>
		</item>
		<item>
			<title><![CDATA[Re: Making tooltips shown after pressed until another marker is pressed.]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1366#p1366</link>
			<description><![CDATA[<p>Thanks. I just checked it out. </p><p>It shows the tooltip, after press/relase. but the tooltip follows around the mouse instead of stick with the marker it blongs to.<br />I am looking into the script see what&#039;s causing that.</p>]]></description>
			<author><![CDATA[null@example.com (lengxin)]]></author>
			<pubDate>Mon, 17 Oct 2016 13:59:14 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1366#p1366</guid>
		</item>
		<item>
			<title><![CDATA[Re: Making tooltips shown after pressed until another marker is pressed.]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1364#p1364</link>
			<description><![CDATA[<p>Hello.</p><p>You can do this without any code modification:<br /></p><div class="codebox"><pre><code>using UnityEngine;

public class ShowMarkersOnPressExample:MonoBehaviour
{
    private OnlineMapsMarkerBase activeMarker;
    private OnlineMaps map;

    private void Start()
    {
        map = OnlineMaps.instance;
        map.showMarkerTooltip = OnlineMapsShowMarkerTooltip.onPress;

        // Add an event to the markers created by the inspector
        foreach (OnlineMapsMarker marker in map.markers) marker.OnPress += OnMarkerPress;

        // Add an event to a new dynamic marker
        map.AddMarker(map.position, &quot;Dynamic marker&quot;).OnPress += OnMarkerPress;

        // Subscribe to OnUpdateAfter
        OnlineMapsControlBase.instance.OnUpdateAfter += OnUpdateAfter;
    }

    /// &lt;summary&gt;
    /// This event occurs at end Update
    /// &lt;/summary&gt;
    private void OnUpdateAfter()
    {
        // If activeMarker exists, restore tootip
        if (activeMarker != null)
        {
            map.tooltipMarker = activeMarker;
            map.tooltip = activeMarker.label;
        }
    }

    /// &lt;summary&gt;
    /// This event occurs on marker press
    /// &lt;/summary&gt;
    /// &lt;param name=&quot;marker&quot;&gt;Instance of marker&lt;/param&gt;
    private void OnMarkerPress(OnlineMapsMarkerBase marker)
    {
        // Change active marker
        activeMarker = marker;
    }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Mon, 17 Oct 2016 06:49:19 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1364#p1364</guid>
		</item>
		<item>
			<title><![CDATA[Re: Making tooltips shown after pressed until another marker is pressed.]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1363#p1363</link>
			<description><![CDATA[<p>Managed to achieve this by comments the lines below out. </p><p><span style="color: blue"><br />&nbsp; &nbsp; &nbsp; &nbsp; if (api.showMarkerTooltip == OnlineMapsShowMarkerTooltip.onPress &amp;&amp; (api.tooltipMarker != null || api.tooltipDrawingElement != null))<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Debug.Log(&quot;Marker released&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //api.tooltipMarker = null;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //api.tooltipDrawingElement = null;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //api.tooltip = null;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br /></span></p><p>Not sure if this goint to cause issues down the line thouse.</p>]]></description>
			<author><![CDATA[null@example.com (lengxin)]]></author>
			<pubDate>Sun, 16 Oct 2016 22:20:50 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1363#p1363</guid>
		</item>
		<item>
			<title><![CDATA[Making tooltips shown after pressed until another marker is pressed.]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1362#p1362</link>
			<description><![CDATA[<p>When change &quot; Show marker tooltip &quot; to &quot;Pressed,&nbsp; the tooltips disappear after the press is released/mouse up ? How can I make it stay until next marker is pressed ? </p><p>Thanks.</p>]]></description>
			<author><![CDATA[null@example.com (lengxin)]]></author>
			<pubDate>Sun, 16 Oct 2016 22:02:18 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1362#p1362</guid>
		</item>
	</channel>
</rss>
