private static IEnumerator partsCombiner(Request request, AvatarDefinition definition, BodyColorMaterialProperties bodycolor, List <ViewPart> parts, int maxAtlasDimension) { int meshCount = parts.Count; Mesh[] meshes = new Mesh[meshCount]; int[][] meshBoneIndexes = new int[meshCount][]; for (int i = 0; i < meshCount; i++) { string[] boneNames = parts[i].GetBoneNames(); meshes[i] = parts[i].GetMesh(); meshBoneIndexes[i] = new int[boneNames.Length]; for (int j = 0; j < boneNames.Length; j++) { meshBoneIndexes[i][j] = definition.BoneIndexLookup[boneNames[j]]; } } request.Mesh = Combine.CombineSkinnedMeshes(meshes, meshBoneIndexes, definition.BindPose); yield return(null); int curSize; Rect[] atlasUVOffsets = Combine.CalculateAtlasLayout(parts, out curSize); yield return(null); int renderTextureSize = Mathf.Min(Mathf.ClosestPowerOfTwo(curSize), maxAtlasDimension); request.Atlas = new RenderTexture(renderTextureSize, renderTextureSize, 0, RenderTextureFormat.ARGB32); request.Atlas.isPowerOfTwo = true; request.Atlas.filterMode = FilterMode.Bilinear; request.Atlas.useMipMap = false; Combine.BakeTexture(parts, atlasUVOffsets, bodycolor, request.Atlas); yield return(null); Combine.ApplyAtlasUV(meshes, request.Mesh, atlasUVOffsets); }
bool IEnumerator.MoveNext() { bool result; switch (this.__1__state) { case 0: this.__1__state = -1; this._meshCount_5__1 = this.parts.Count; this._meshes_5__2 = new Mesh[this._meshCount_5__1]; this._meshBoneIndexes_5__3 = new int[this._meshCount_5__1][]; for (int i = 0; i < this._meshCount_5__1; i++) { string[] boneNames = this.parts[i].GetBoneNames(); this._meshes_5__2[i] = this.parts[i].GetMesh(); this._meshBoneIndexes_5__3[i] = new int[boneNames.Length]; for (int j = 0; j < boneNames.Length; j++) { this._meshBoneIndexes_5__3[i][j] = this.definition.BoneIndexLookup[boneNames[j]]; } } this.request.Mesh = Combine.CombineSkinnedMeshes(this._meshes_5__2, this._meshBoneIndexes_5__3, this.definition.BindPose); this.__2__current = null; this.__1__state = 1; result = true; return(result); case 1: this.__1__state = -1; this._atlasUVOffsets_5__5 = Combine.CalculateAtlasLayout(this.parts, out this._curSize_5__4); this.__2__current = null; this.__1__state = 2; result = true; return(result); case 2: this.__1__state = -1; this._renderTextureSize_5__6 = Mathf.Min(Mathf.ClosestPowerOfTwo(this._curSize_5__4), this.maxAtlasDimension); this.request.Atlas = new RenderTexture(this._renderTextureSize_5__6, this._renderTextureSize_5__6, 0, RenderTextureFormat.ARGB32); this.request.Atlas.isPowerOfTwo = true; this.request.Atlas.filterMode = FilterMode.Bilinear; this.request.Atlas.useMipMap = false; Combine.BakeTexture(this.parts, this._atlasUVOffsets_5__5, this.bodycolor, this.request.Atlas); this.__2__current = null; this.__1__state = 3; result = true; return(result); case 3: this.__1__state = -1; Combine.ApplyAtlasUV(this._meshes_5__2, this.request.Mesh, this._atlasUVOffsets_5__5); break; } result = false; return(result); }