public void rebuildMesh()
        {
            if (!skinMeshRend)
            {
                return;
            }
            var resMap = new ResourceMapper();
            //jsonMesh = new JsonMesh(new Mesh)

            var prefabRoot        = ExportUtility.getLinkedRootPrefabAsset(skinMeshRend.gameObject);
            var assetSkeletonRoot = JsonSkeletonBuilder.findSkeletonRoot(skinMeshRend);
            var mesh = skinMeshRend.sharedMesh;

            jsonMesh = new JsonMesh(new MeshStorageKey(mesh, prefabRoot, assetSkeletonRoot), 0, resMap);

            var boneNames = skinMeshRend.bones.Select((arg) => arg.name).ToList();

            origTransforms = skinMeshRend.bones.ToList();
            if (skeletonRoot)
            {
                debugTransforms = Utility.findNamedTransforms(boneNames, skeletonRoot);
            }
            else
            {
                debugTransforms = null;
            }
            //var foundTransforms = boneNames.Select((arg) => ;
        }
        public ResId getRootPrefabId(GameObject obj, bool createMissing)
        {
            if (!obj)
            {
                return(ResId.invalid);               //ExportUtility.invalidId;
            }
            var rootPrefab = ExportUtility.getLinkedRootPrefabAsset(obj);

            if (!rootPrefab)
            {
                return(ResId.invalid);               //ExportUtility.invalidId;
            }
            var result = prefabs.getId(rootPrefab, createMissing, onNewRootPrefab);

            return(result);
        }
Пример #3
0
        public static JsonSkeleton extractOriginalSkeleton(SkinnedMeshRenderer meshRend, Logger logger)
        {
            Logger.makeValid(ref logger);
            var rootPrefab = ExportUtility.getLinkedRootPrefabAsset(meshRend.gameObject);            //PrefabUtility.FindPrefabRoot(meshRend.gameObject);

            if (!rootPrefab)
            {
                //now what?
                logger.logWarningFormat("Could not find original prefab for meshRenderer {0}({1}),"
                                        + "falling back on generating unique skeleton, errors may occur",
                                        meshRend, meshRend.gameObject
                                        );
                return(buildFromSkinMesh(meshRend));
            }
            return(buildFromPrefabRoot(rootPrefab));
        }