<?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 — Overlay Issue]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=2062</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=2062&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Overlay Issue.]]></description>
		<lastBuildDate>Fri, 18 Nov 2022 15:49:18 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Overlay Issue]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8749#p8749</link>
			<description><![CDATA[<p>Legend thanks!</p>]]></description>
			<author><![CDATA[null@example.com (AT_Mike)]]></author>
			<pubDate>Fri, 18 Nov 2022 15:49:18 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8749#p8749</guid>
		</item>
		<item>
			<title><![CDATA[Re: Overlay Issue]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8748#p8748</link>
			<description><![CDATA[<p>You can&#039;t set this to Start because the tiles might not exist yet.<br />You have two ways:<br />1. Use OnlineMapsTileManager.OnPrepareDownloadTile to set alpha = 0.<br />2. (not recommended) Modify the source code to set 0 as the default value.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 18 Nov 2022 15:19:52 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8748#p8748</guid>
		</item>
		<item>
			<title><![CDATA[Re: Overlay Issue]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8747#p8747</link>
			<description><![CDATA[<div class="quotebox"><cite>Alex Vertax wrote:</cite><blockquote><p>Hello.</p><p>In Update, after you have set overlayBackAlpha for all tiles, you need to call OnlineMaps.instance.Redraw().</p></blockquote></div><p>Ahhh of course I see.<br />Thanks very much.</p><p>What about if I wanted to set the alpha to 0 after the start btw?<br />It seems to lock to lock to 1 even if I set it in a few places in the start</p>]]></description>
			<author><![CDATA[null@example.com (AT_Mike)]]></author>
			<pubDate>Fri, 18 Nov 2022 14:59:58 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8747#p8747</guid>
		</item>
		<item>
			<title><![CDATA[Re: Overlay Issue]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8744#p8744</link>
			<description><![CDATA[<p>Hello.</p><p>In Update, after you have set overlayBackAlpha for all tiles, you need to call OnlineMaps.instance.Redraw().</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 18 Nov 2022 14:21:16 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8744#p8744</guid>
		</item>
		<item>
			<title><![CDATA[Overlay Issue]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8742#p8742</link>
			<description><![CDATA[<p>Hello!<br />I&#039;ve used the overlay example below to create an overlay with a toggle button<br /><a href="https://infinity-code.com/atlas/online-maps/pages/TilesetMapTilerOverlayExample.html">https://infinity-code.com/atlas/online- … ample.html</a></p><p>The issue I&#039;m facing is that the overlay always shows no matter what the alpha is set to.<br />It is worth noting that I don&#039;t have the full content to use yet so I&#039;ve only been using one zoom level of another map, but I don&#039;t think that should affect it.</p><p>Am I missing something with regard to how this works? Code is below but I believe this would happen with the unedited code from the overlay page.</p><p>Thanks</p><div class="codebox"><pre><code>using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ShipwrecksToggle : MonoBehaviour
{
    public string overlayPath;
    public Sprite toggleOn;
    public Sprite toggleOff;
    public Image toggleImage;
    private bool toggle = false;

    // Overlay transparency
    [Range(0, 1)]
    public float alpha = 1;

    private float _alpha = 1;

    private void Start()
    {
        toggle = false;
        toggleImage.sprite = toggleOff;
        alpha = 0f;

        if (OnlineMapsCache.instance != null)
        {
            // Subscribe to the cache events.
            OnlineMapsCache.instance.OnLoadedFromCache += LoadTileOverlay;
        }

        // Subscribe to the tile download event.
        OnlineMapsTileManager.OnStartDownloadTile += OnStartDownloadTile;
    }

    private static void LoadTileOverlay(OnlineMapsTile tile)
    {
        // Load overlay for tile from Resources.
        string path = string.Format(&quot;OnlineMapsOverlay/{0}/{1}/{2}&quot;, tile.zoom, tile.x, tile.y);
        Texture2D texture = Resources.Load&lt;Texture2D&gt;(path);

        if (texture != null)
        {
            tile.overlayBackTexture = Instantiate(texture);
            Resources.UnloadAsset(texture);
        }
    }

    private void OnStartDownloadTile(OnlineMapsTile tile)
    {
        // Load overlay for tile.
        LoadTileOverlay(tile);

        // Load the tile using a standard loader.
        OnlineMapsTileManager.StartDownloadTile(tile);
    }

    private void Update()
    {
        // Update the transparency of overlay.
        if (Math.Abs(_alpha - alpha) &gt; float.Epsilon)
        {
            _alpha = alpha;
            lock (OnlineMapsTile.lockTiles)
            {
                foreach (OnlineMapsTile tile in OnlineMaps.instance.tileManager.tiles) tile.overlayBackAlpha = alpha;
            }
        }
    }

    public void ToggleOverlay()
    {
        toggle = !toggle;

        if(toggle == true)
        {
            toggleImage.sprite = toggleOn;
            alpha = 1f;
        }
        else
        {
            toggleImage.sprite = toggleOff;
            alpha = 0f;
        }
    }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (AT_Mike)]]></author>
			<pubDate>Fri, 18 Nov 2022 12:20:46 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8742#p8742</guid>
		</item>
	</channel>
</rss>
