using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
public class DrawBlockMeshTexture : MonoBehaviour {
// Use this for initialization
void Start () {
int size = 10;
Texture2D colorTxt = new Texture2D(360* size, 181* size);
//colorTxt.filterMode = FilterMode.Point;
for (int i = 0; i != colorTxt.height; i++)
{
int lat = i / size;
// 纬线圈lat上对应的方块个数
int blockNumAtLatitude = Mathf.CeilToInt(360 * Mathf.Cos((lat-90) * Mathf.Deg2Rad));
if (blockNumAtLatitude == 0)
continue;
// 每一个小块对应的像素跨度
int pixPerBlock = colorTxt.width / blockNumAtLatitude;
for (int j = 0; j != colorTxt.width; j++)
{
if (j % pixPerBlock == 0)
colorTxt.SetPixel(j, i, Color.green);
if (i % size == 0)
colorTxt.SetPixel(j, i, Color.red);
}
}
colorTxt.Apply();
byte[] bytes = colorTxt.EncodeToPNG();
File.WriteAllBytes(Application.dataPath + "/BlockMeshTexture.png", bytes);
}
// Update is called once per frame
void Update () {
}
}