private void SetMapIcon(string path, GameObject display) { string iconPath = Screenshotter.GetMapIconPath(path); MeshRenderer renderer = display.GetComponent <MeshRenderer>(); Material mat = new Material(Shader.Find("Legacy Shaders/Diffuse")); if (File.Exists(iconPath)) { Texture2D texture = new Texture2D(Screenshotter.SIZE_X, Screenshotter.SIZE_Y, TextureFormat.RGB24, false); byte[] bytes = File.ReadAllBytes(iconPath); texture.LoadImage(bytes, false); texture.Apply(); mat.mainTexture = texture; } renderer.material = mat; }
/// <summary> /// Takes screenshot of current map and saves it to JPG file. /// </summary> private void MakeMapMiniature() { CameraSettings(); for (int y = 0; y < mapSize.y; y++) { for (int x = 0; x < mapSize.x; x++) { grid[y, x].SetActive(false); } } cam.transform.GetChild(0).GetComponent <Camera>().enabled = false; Screenshotter.TakeScreenshot(Screenshotter.GetMapIconPath(mapPath), cam); cam.transform.GetChild(0).GetComponent <Camera>().enabled = true; for (int y = 0; y < mapSize.y; y++) { for (int x = 0; x < mapSize.x; x++) { grid[y, x].SetActive(true); } } }