public IEnumerable <TaskInfo> ImportIE(MeshSequence t) { yield return(new TaskInfo("Prepare importing", 0)); if (ProjectionSamples.Get == null) { yield return(new TaskInfo("Missing Projection Samples asset. Reinstal Vertex Animation Tools package", -1)); yield break; } t.PreImport.MSI = new MeshSequenceInfo(t.PreImport.PathToObj, t.PreImport.FilesSortMode); if (t.PreImport.MSI.State != MeshSequenceInfo.StateEnum.Ready) { yield return(new TaskInfo(t.PreImport.MSI.ShortInfo, -1)); } t.PreImport.VColorSettings.go = gameObject; int importFrom = 0; int importTo = t.PreImport.MSI.Count; int totalFramesCount = t.PreImport.MSI.Count; if (t.PreImport.ImportCustomRange) { importFrom = Mathf.Clamp(t.PreImport.ImportFromFrame, 0, t.PreImport.MSI.Count); importTo = Mathf.Clamp(t.PreImport.ImportToFrame, 0, t.PreImport.MSI.Count); totalFramesCount = Mathf.Clamp(importTo - importFrom, 0, int.MaxValue); } t.SequenceVerticesCount = new NumbersRange(true); t.SequenceObjVerticesCount = new NumbersRange(true); t.SequenceTrianglesCount = new NumbersRange(true); t.SequenceObjPolygonsCount = new NumbersRange(true); t.SequenceSubmeshesCount = new NumbersRange(true); t.SetMaterialsUnused(); List <MeshSequence.Frame> nframes = new List <MeshSequence.Frame>(); int counter = 0; for (int f = importFrom; f < importTo; f++) { string objName = Path.GetFileNameWithoutExtension(t.PreImport.MSI[f].fi.FullName); MeshSequence.Frame frame = t.GetFrameByName(objName); ObjData od = new ObjData(t.PreImport.MSI[f].fi.FullName); od.NormalsRecalculationMode = t.PreImport.NormalRecalculationMode; od.FlipNormals = t.PreImport.FlipNormals; od.SmoothingGroupsMode = t.PreImport.SmoothingGroupImportMode; od.ImportUV = t.PreImport.ImportUV; od.CalculateNormals = t.PreImport.CalculateNormals; od.CalculateTangents = t.PreImport.CalculateTangents; #if UNITY_2017_3_OR_NEWER od.IndexFormat = t.PreImport.IndexFormat; #endif od.Build(); od.Apply(t.PreImport.SwapYZAxis, t.PreImport.ScaleFactor); od.CopyTo(frame.FrameMesh); if (t.PreImport.GenerateMaterials) { frame.Materials = t.GetPolygonalMeshMaterials(od.SubMeshes.GetNames()); } if (od.CalcVertexColor(t.PreImport.VColorSettings)) { frame.FrameMesh.colors = od.UM_colors; } frame.MeshTrisCount = frame.FrameMesh.triangles.Length / 3; frame.MeshVertsCount = frame.FrameMesh.vertexCount; frame.ObjVerticesCount = od.Vertices.Count; frame.ObjPolygonsCount = od.AllPolygons.Count; t.SequenceSubmeshesCount.Set(od.SubMeshes.Count); t.SequenceVerticesCount.Set(frame.FrameMesh.vertexCount); t.SequenceObjVerticesCount.Set(frame.FrameMesh.triangles.Length / 3); t.SequenceTrianglesCount.Set(od.Vertices.Count); t.SequenceObjPolygonsCount.Set(od.AllPolygons.Count); nframes.Add(frame); TaskInfo ti = new TaskInfo(string.Format("Importing frame #{0}", f), counter / (float)totalFramesCount); counter++; yield return(ti); } t.PreImport.NormalizedPerFrame = 1f / (float)nframes.Count; t.PreImport.ImportDate = System.DateTime.Now.ToString(); t.PostImport = t.PreImport; t.Frames = nframes; t.ClearUnusedMaterials(); }