public static void RemoveBone(this UnityDisplayNode unityDisplayNode, string boneName, bool alreadyUnbound = false) { var skinnedMeshRenderer = unityDisplayNode.GetRenderer <SkinnedMeshRenderer>(); if (!alreadyUnbound) { // Unbind the mesh so we can change it without affecting the original skinnedMeshRenderer.UnbindMesh(); } // Get the bone index that controls the Boomerang var boomerang = skinnedMeshRenderer.GetBoneIndex(boneName); // Get all vertices that the bone controls var badVertices = skinnedMeshRenderer.GetVerticesConnectedToBoneArray(boomerang); // Remove all triangles that contain any of those vertices var triangles = skinnedMeshRenderer.GetTrianglesAsArrays(); triangles.RemoveAll(triangle => triangle.Any(v => badVertices[v])); skinnedMeshRenderer.SetTriangles(triangles); }
/// <summary> /// Sets the sprite texture to that of a named png /// </summary> /// <param name="node">The UnityDisplayNode</param> /// <param name="textureName">The name of the texture, without .png</param> protected void Set2DTexture(UnityDisplayNode node, string textureName) { node.GetRenderer <SpriteRenderer>().sprite = GetSprite(textureName, PixelsPerUnit); }