本文整理汇总了C#中UnityEngine.Texture2D.FillPolygon方法的典型用法代码示例。如果您正苦于以下问题:C# Texture2D.FillPolygon方法的具体用法?C# Texture2D.FillPolygon怎么用?C# Texture2D.FillPolygon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Texture2D
的用法示例。
在下文中一共展示了Texture2D.FillPolygon方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowElevation
public void ShowElevation(GameObject plane, Map2 map)
{
var textureWidth = (int)Map1.Width * _textureScale;
var textureHeight = (int)Map1.Height * _textureScale;
var texture = new Texture2D(textureWidth, textureHeight, TextureFormat.RGB565, true);
texture.SetPixels(Enumerable.Repeat(BiomeProperties.Colors[Biome.Ocean], textureWidth * textureHeight).ToArray());
//绘制陆地
var lands = map.Graph.centers.Where(p => !p.ocean);
foreach (var land in lands)
texture.FillPolygon(
land.corners.Select(p => p.point * _textureScale).ToArray(),
BiomeProperties.Colors[Biome.Beach] * land.elevation);
//绘制边缘
var lines = map.Graph.edges.Where(p => p.v0 != null).Select(p => new[]
{
p.v0.point.x, p.v0.point.y,
p.v1.point.x, p.v1.point.y
}).ToArray();
foreach (var line in lines)
DrawLine(texture, line[0], line[1], line[2], line[3], Color.black);
//绘制中心点
var points = map.Graph.centers.Select(p => p.point).ToList();
foreach (var p in points)
texture.SetPixel((int)(p.x * _textureScale), (int)(p.y * _textureScale), Color.red);
texture.Apply();
plane.GetComponent<Renderer>().material.mainTexture = texture;
}
示例2: AttachTexture
public void AttachTexture(GameObject plane, Map map)
{
int _textureWidth = (int)Map.Width * _textureScale;
int _textureHeight = (int)Map.Height * _textureScale;
Texture2D texture = new Texture2D(_textureWidth, _textureHeight, TextureFormat.RGBA32, false);
texture.wrapMode = TextureWrapMode.Clamp;
foreach (var c in map.Graph.centers)
{
var corner = new Vector2[c.corners.Count];
for (int i = 0; i < corner.Length; i++)
{
var p = c.corners[i];
corner[i] = new Vector2(p.point.x * _textureScale, p.point.y * _textureScale);
}
texture.FillPolygon(corner, BiomeProperties.Colors[c.biome]);
}
texture.Apply();
var render = plane.GetComponent<Renderer>();
render.material.mainTexture = texture;
mapScale = render.bounds.size.x;
}
示例3: AttachTexture
public void AttachTexture(GameObject plane, Map map)
{
int _textureWidth = (int)Map.Width * _textureScale;
int _textureHeight = (int)Map.Height * _textureScale;
Texture2D texture = new Texture2D(_textureWidth, _textureHeight);
texture.SetPixels(Enumerable.Repeat(Color.magenta, _textureWidth * _textureHeight).ToArray());
var lines = map.Graph.edges.Where(p => p.v0 != null).Select(p => new[]
{
p.v0.point.x, p.v0.point.y,
p.v1.point.x, p.v1.point.y
}).ToArray();
foreach (var c in map.Graph.centers)
texture.FillPolygon(c.corners.Select(p => new Vector2(p.point.x * _textureScale, p.point.y * _textureScale)).ToArray(), BiomeProperties.Colors[c.biome]);
foreach (var line in lines)
DrawLine(texture, line[0], line[1], line[2], line[3], Color.black);
foreach (var line in map.Graph.edges.Where(p => p.river > 0 && !p.d0.water && !p.d1.water))
DrawLine(texture, line.v0.point.x, line.v0.point.y, line.v1.point.x, line.v1.point.y, Color.blue);
texture.Apply();
plane.renderer.material.mainTexture = texture;
plane.transform.localPosition = new Vector3(Map.Width / 2, Map.Height / 2, 1);
}
示例4: DrawNoisyPolygon
private void DrawNoisyPolygon(Texture2D texture, Center p, List<Vector2> orgEdges)
{
_edgePoints.Clear();
_edgePoints.AddRange(orgEdges);
_edgePoints.Add(p.point);
texture.FillPolygon(
_edgePoints.Select(x => new Vector2(x.x * _textureScale, x.y * _textureScale)).ToArray(),
BiomeProperties.Colors[p.biome]);
}