本文整理汇总了C#中Layer.renderUv方法的典型用法代码示例。如果您正苦于以下问题:C# Layer.renderUv方法的具体用法?C# Layer.renderUv怎么用?C# Layer.renderUv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Layer
的用法示例。
在下文中一共展示了Layer.renderUv方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMesh
public Mesh CreateMesh()
{
// We use the currentLayer ID to order them on the Z axis.
int currentLayerID = 0;
// UsedVertices is used to maintain a count of the vertices between
//layers so when you call renderTriangles, it nows where to start.
int usedVertices = 0;
TileSet tileset = null;
List<Vector3> vertices = new List<Vector3> ();
List<Vector2> uv = new List<Vector2> ();
List<int> triangles = new List<int> ();
Mesh mesh = new Mesh ();
// What we're doing here is simple: Load the xml file from the attributes
// And start parsing. Once it finds a tileset element it creates the tileset object
// (it will be the first thing it encounters)
XmlDocument xmldoc = new XmlDocument ();
xmldoc.Load (new StringReader (tilemap.text));
XmlNodeList nodelist = xmldoc.DocumentElement.ChildNodes;
foreach (XmlNode outerNode in nodelist) {
switch (outerNode.Name) {
case "tileset":
// Basically we just grab the data from the xml and build a Tileset object
// To avoid problems with the collision tileset since we only store one tileset
// we ignore anything with Collision inside.
if (outerNode.Attributes ["name"].InnerText.IndexOf ("Collision") == -1) {
XmlNode imageNode = outerNode.SelectSingleNode ("image");
int firstGID = int.Parse (outerNode.Attributes ["firstgid"].InnerText);
int width = int.Parse (outerNode.Attributes ["tilewidth"].InnerText);
int height = int.Parse (outerNode.Attributes ["tileheight"].InnerText);
int imageWidth = int.Parse (imageNode.Attributes ["width"].InnerText);
int imageheight = int.Parse (imageNode.Attributes ["height"].InnerText);
int tileBorder = 0;
if (outerNode.Attributes ["spacing"] != null)
tileBorder = int.Parse (outerNode.Attributes ["spacing"].InnerText);
tileset = new TileSet (firstGID, width, height, imageWidth, imageheight, tileBorder);
}
break;
case "layer":
// First we build the layer object and then just call the renderVertices
// renderUV and renderTriangles to build our textured mesh.
// Finally we store the vertexcount and +1 to the currentLayerID.
// like in the tileset, we avoid using the "collision_" layers since
// they only contain collision info
if (outerNode.Attributes ["name"].InnerText.IndexOf ("collision_") == -1) {
XmlNode dataNode = outerNode.SelectSingleNode ("data");
int layerWidth = int.Parse (outerNode.Attributes ["width"].InnerText);
int layerHeight = int.Parse (outerNode.Attributes ["height"].InnerText);
string csvData = dataNode.InnerText;
Layer currentLayer = new Layer (tileset, csvData, currentLayerID, layerWidth, layerHeight);
vertices.AddRange (currentLayer.renderVertices ());
uv.AddRange (currentLayer.renderUv ());
triangles.AddRange (currentLayer.renderTriangles (usedVertices, usedVertices+currentLayer.vertexCount));
usedVertices += currentLayer.vertexCount;
}
currentLayerID += 1;
break;
}
}
mesh.vertices = vertices.ToArray ();
mesh.uv = uv.ToArray ();
mesh.triangles = triangles.ToArray ();
return mesh;
}