Пример #1
0
        SkinnedMeshRenderer _Erase(GameObject go)
        {
            if (go == null)
            {
                Debug.LogWarning("select root object in hierarchy");
                return(null);
            }
            if (m_skinnedMesh == null)
            {
                Debug.LogWarning("no skinnedmesh");
                return(null);
            }

            var bones      = m_skinnedMesh.bones;
            var eraseBones = m_eraseBones
                             .Where(x => x.Erase)
                             .Select(x => Array.IndexOf(bones, x.Bone))
                             .ToArray();

            var meshNode = new GameObject("BoneMeshEraser");

            meshNode.transform.SetParent(go.transform, false);

            var erased = meshNode.AddComponent <SkinnedMeshRenderer>();

            erased.sharedMesh      = BoneMeshEraser.CreateErasedMesh(m_skinnedMesh.sharedMesh, eraseBones);
            erased.sharedMaterials = m_skinnedMesh.sharedMaterials;
            erased.bones           = m_skinnedMesh.bones;

            return(erased);
        }
        private SkinnedMeshRenderer Remove(GameObject go)
        {
            var bones      = _cSkinnedMesh.bones;
            var eraseBones = _eraseBones
                             .Where(x => x.Erase)
                             .Select(x => Array.IndexOf(bones, x.Bone))
                             .ToArray();

            var meshNode = new GameObject(BoneMeshEraserWizard.BONE_MESH_ERASER_NAME);

            meshNode.transform.SetParent(go.transform, false);

            var erased = meshNode.AddComponent <SkinnedMeshRenderer>();

            erased.sharedMesh      = BoneMeshEraser.CreateErasedMesh(_cSkinnedMesh.sharedMesh, eraseBones);
            erased.sharedMaterials = _cSkinnedMesh.sharedMaterials;
            erased.bones           = _cSkinnedMesh.bones;

            return(erased);
        }