Topic: How to force a redraw?

Hello all,

I have two map tile sets that are in the resources folder. I have a basic toggle that changes the resourcesPath on button press, and then call RedrawImmediately expecting this to load the second tile set.
This doesn't work, however, as I seem to be missing a step. It does display the new map but only for newly loaded tiles when either the user scrolls or zooms out.

Just wondering how I should go about reloading the map using the new resourcesPath?

I've tried calling redraw, redraw immediately, and changing the variables that state whether a redraw should occur.

Thanks

Re: How to force a redraw?

Hello.

You need to reset the tile manager.
Something like:

using UnityEngine;

namespace InfinityCode.OnlineMapsSupport
{
    public class ChangeResourcesPath : MonoBehaviour
    {
        public string path1 = "OnlineMapsTiles/type1/{zoom}/{x}/{y}";
        public string path2 = "OnlineMapsTiles/type2/{zoom}/{x}/{y}";

        private void OnGUI()
        {
            if (GUILayout.Button("Change"))
            {
                OnlineMaps.instance.resourcesPath = OnlineMaps.instance.resourcesPath == path1 ? path2 : path1;
                OnlineMaps.instance.tileManager.Reset();
                OnlineMaps.instance.Redraw();
            }
        }

        private void Start()
        {
            OnlineMaps.instance.resourcesPath = path1;
        }
    }
}
Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: How to force a redraw?

Awesome thanks!