當前位置: 首頁>>代碼示例>>C#>>正文


C# Mesh.GetUVs方法代碼示例

本文整理匯總了C#中UnityEngine.Mesh.GetUVs方法的典型用法代碼示例。如果您正苦於以下問題:C# Mesh.GetUVs方法的具體用法?C# Mesh.GetUVs怎麽用?C# Mesh.GetUVs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UnityEngine.Mesh的用法示例。


在下文中一共展示了Mesh.GetUVs方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: z_SplatSet

		public z_SplatSet(Mesh mesh, z_MeshChannel[] channelMap)
		{
			List<Vector4> 	uv0 = new List<Vector4>(),
							uv2 = new List<Vector4>(),
							uv3 = new List<Vector4>(),
							uv4 = new List<Vector4>();

			mesh.GetUVs(0, uv0);
			mesh.GetUVs(1, uv2);
			mesh.GetUVs(2, uv3);
			mesh.GetUVs(3, uv4);

			Color32[] color = mesh.colors32;
			Vector4[] tangent = mesh.tangents;

			int vertexCount = mesh.vertexCount;
			int channelCount = channelMap.Length;
			
			this.channelMap = channelMap;
			this.weights = z_Util.Fill<z_SplatWeight>((index) => { return new z_SplatWeight(channelCount * 4); }, vertexCount);	

			for(int n = 0; n < channelCount; n++)
			{
				int index = n * COMPONENTS_PER_ATTRIBUTE;

				switch(channelMap[n])
				{
					case z_MeshChannel.UV0:
					{
						if(uv0 == null || uv0.Count != vertexCount)
							goto case z_MeshChannel.NULL;

						for(int i = 0; i < vertexCount; i++)
							this.weights[i].Set(index, uv0[i]);

						break;
					}

					case z_MeshChannel.UV2:
					{
						if(uv2 == null || uv2.Count != vertexCount)
							goto case z_MeshChannel.NULL;

						for(int i = 0; i < vertexCount; i++)
							this.weights[i].Set(index, uv2[i]);

						break;
					}

					case z_MeshChannel.UV3:
					{
						if(uv3 == null || uv3.Count != vertexCount)
							goto case z_MeshChannel.NULL;

						for(int i = 0; i < vertexCount; i++)
							this.weights[i].Set(index, uv3[i]);

						break;
					}

					case z_MeshChannel.UV4:
					{
						if(uv4 == null || uv4.Count != vertexCount)
							goto case z_MeshChannel.NULL;

						for(int i = 0; i < vertexCount; i++)
							this.weights[i].Set(index, uv4[i]);

						break;
					}

					case z_MeshChannel.COLOR:
					{
						if(color == null || color.Length != vertexCount)
							goto case z_MeshChannel.NULL;


						for(int i = 0; i < vertexCount; i++)
							this.weights[i].Set(index, color[i]);

						break;
					}

					case z_MeshChannel.TANGENT:
					{
						if(tangent == null || tangent.Length != vertexCount)
							goto case z_MeshChannel.NULL;


						for(int i = 0; i < vertexCount; i++)
							this.weights[i].Set(index, tangent[i]);

						break;
					}

					case z_MeshChannel.NULL:
					{
						for(int i = 0; i < vertexCount; i++)
							this.weights[i].Set(index, Color32_Black);
						break;
//.........這裏部分代碼省略.........
開發者ID:alex-carlson,項目名稱:PixelitisGGJ,代碼行數:101,代碼來源:z_SplatSet.cs

示例2: Copy

		/**
		 *	Copy @src mesh values to @dest
		 */
		public static void Copy(Mesh dest, Mesh src)
		{
			dest.Clear();
			dest.vertices = src.vertices;

			List<Vector4> uvs = new List<Vector4>();

			src.GetUVs(0, uvs); dest.SetUVs(0, uvs);
			src.GetUVs(1, uvs); dest.SetUVs(1, uvs);
			src.GetUVs(2, uvs); dest.SetUVs(2, uvs);
			src.GetUVs(3, uvs); dest.SetUVs(3, uvs);

			dest.normals = src.normals;
			dest.tangents = src.tangents;
			dest.boneWeights = src.boneWeights;
			dest.colors = src.colors;
			dest.colors32 = src.colors32;
			dest.bindposes = src.bindposes;

			dest.subMeshCount = src.subMeshCount;

			for(int i = 0; i < src.subMeshCount; i++)
				dest.SetIndices(src.GetIndices(i), src.GetTopology(i), i);

			dest.name = z_Util.IncrementPrefix("z", src.name);
		}
開發者ID:alex-carlson,項目名稱:PixelitisGGJ,代碼行數:29,代碼來源:z_MeshUtility.cs


注:本文中的UnityEngine.Mesh.GetUVs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。