本文整理汇总了C#中Mesh.GetInstanceID方法的典型用法代码示例。如果您正苦于以下问题:C# Mesh.GetInstanceID方法的具体用法?C# Mesh.GetInstanceID怎么用?C# Mesh.GetInstanceID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mesh
的用法示例。
在下文中一共展示了Mesh.GetInstanceID方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
void Start()
{
sharedMesh = GetComponent<MeshFilter>().sharedMesh;
if (sharedMesh == null)
{
Debug.Log("[RPGMesh] No MeshFilter.sharedMesh object found");
enabled = false;
return;
}
meshId = sharedMesh.GetInstanceID();
if (!triangleTrees.ContainsKey(meshId))
{
triangleTrees[meshId] = new RPGTriangleTree(GetComponent<MeshCollider>());
}
}
示例2: GetMeshIdent
string GetMeshIdent( Mesh mesh )
{
return mesh.name + "_" + mesh.GetInstanceID();
}
示例3: SaveMesh
public static string SaveMesh(Mesh mesh, string path)
{
if (savedMeshes.ContainsKey(mesh.name))
{
if (savedMeshes[mesh.name].GetInstanceID() != mesh.GetInstanceID())
{
Debug.LogError("有重名mesh:"+mesh.name);
}
return mesh.name;
}
if (System.IO.Directory.Exists(path) == false)
{
System.IO.Directory.CreateDirectory(path);
}
using (System.IO.Stream s = System.IO.File.Open(System.IO.Path.Combine(path, mesh.name + ".mesh.bytes"), System.IO.FileMode.Create))
{
byte[] buf = BitHelper.getBytes(mesh.bounds);
s.Write(buf, 0, 24);
UInt32 vc = (UInt32)mesh.vertexCount;
buf = BitConverter.GetBytes(vc);
s.Write(buf, 0, 4);
if (mesh.vertices != null && mesh.vertices.Length != 0)
{
s.WriteByte(1);//1 vb pos tag
for (int i = 0; i < vc; i++)
{
s.Write(BitHelper.getBytes(mesh.vertices[i]), 0, 12);
if (i == 0)
{
Debug.Log("pos0:" + mesh.vertices[i]);
}
}
}
if (mesh.colors32 != null && mesh.colors32.Length != 0)
{
s.WriteByte(2);//2 vb color tag;
for (int i = 0; i < vc; i++)
{
s.Write(BitHelper.getBytes(mesh.colors32[i]), 0, 4);
Debug.Log("color0:" + mesh.colors32[i]);
if (i == 0)
{
Debug.Log("pos0:" + mesh.vertices[i]);
}
}
}
if (mesh.normals != null && mesh.normals.Length != 0)
{
s.WriteByte(3);//3 vb normal tag;
for (int i = 0; i < vc; i++)
{
s.Write(BitHelper.getBytes(mesh.normals[i]), 0, 12);
if (i == 0)
{
Debug.Log("normal0:" + mesh.normals[i]);
}
}
}
if (mesh.uv != null && mesh.uv.Length != 0)
{
s.WriteByte(4);//4 vb uv tag;
for (int i = 0; i < vc; i++)
{
s.Write(BitHelper.getBytes(mesh.uv[i]), 0, 8);
if (i == 0)
{
Debug.Log("uv0:" + mesh.uv[i]);
}
}
}
if (mesh.uv1 != null && mesh.uv1.Length != 0)
{
s.WriteByte(5);//5 vb uv1 tag;
for (int i = 0; i < vc; i++)
{
s.Write(BitHelper.getBytes(mesh.uv1[i]), 0, 8);
}
}
if (mesh.uv2 != null && mesh.uv2.Length != 0)
{
s.WriteByte(6);//6 vb uv2 tag;
for (int i = 0; i < vc; i++)
{
s.Write(BitHelper.getBytes(mesh.uv[i]), 0, 8);
}
}
s.WriteByte(255);//vb end
int sub = mesh.subMeshCount;
s.WriteByte((byte)sub);
{
Debug.Log("sub:" + sub);
}
for (int i = 0; i < sub; i++)
{
int tv = (int)mesh.GetTopology(i);//绘制方式
s.Write(BitConverter.GetBytes(tv), 0, 4);
var indices = mesh.GetIndices(i);//索引
UInt16 length = (UInt16)indices.Length;
s.Write(BitConverter.GetBytes(length), 0, 2);
//.........这里部分代码省略.........
示例4: GetMeshToAdd
private SelectedMesh GetMeshToAdd(Mesh mesh, bool isProjectAsset, Object _assoObj = null)
{
string meshPath = AssetDatabase.GetAssetPath(mesh);
Mesh meshAsset = AssetDatabase.LoadAssetAtPath(meshPath, typeof(Mesh)) as Mesh;
//If null, it can be a built-in Unity mesh
if(meshAsset == null)
{
return new SelectedMesh(mesh, mesh.name, isProjectAsset, _assoObj);
}
string meshName = mesh.name;
if(!AssetDatabase.IsMainAsset(meshAsset))
{
Object main = AssetDatabase.LoadMainAssetAtPath(meshPath);
meshName = main.name + " - " + meshName + "_" + mesh.GetInstanceID().ToString();
}
SelectedMesh sm = new SelectedMesh(mesh, meshName, isProjectAsset, _assoObj);
return sm;
}
示例5: GetMeshAssetName
private string GetMeshAssetName(Mesh mesh, Vector4 lightmapTilingOffset)
{
string lightmapPostfix = "_" + lightmapTilingOffset.x + "_" + lightmapTilingOffset.y + "_" +
lightmapTilingOffset.z + "_" + lightmapTilingOffset.w;
return mesh.name + lightmapPostfix + "_" + mesh.GetInstanceID().ToString("X8");
}