We are using the minimap in the Picture mode and I am hoping to change the MapTexture whenever I load a new level or step inside a house/cave
Just setting the bl_MiniMap.MapTexture does not work as it needs to call CreateMaterial() for the plane
Please advise how I might update the MapTexture on the fly.
UGUI MiniMap Dynamically set MapTexture
- Lovatto
- Admin
- Posts: 1834
- Joined: Sun Dec 07, 2014 3:18 pm
- Contact:
Hi for do this you will need modify a little the code I will guide you:
in bl_MiniMap.cs add this private var:
now in the funtion void CreateMapPlane() find this line:
and replace with this:
and add this new funtion:
now you can change the map texture like this:
I hope this help you.
in bl_MiniMap.cs add this private var:
Code: Select all
private GameObject plane;
Code: Select all
GameObject plane = Instantiate(MapPlane) as GameObject;
Code: Select all
plane = Instantiate(MapPlane) as GameObject;
Code: Select all
/// <summary>
///
/// </summary>
/// <param name="t"></param>
public void SetMapTexture(Texture t)
{
if(m_Type != RenderType.Picture)
{
Debug.LogWarning("You only can set texture in Picture Mode");
return;
}
plane.GetComponent<MeshRenderer>().material.mainTexture = t;
}
Code: Select all
bl_MiniMapUtils.GetMiniMap().SetMapTexture(YourTexture);