Exemplo n.º 1
0
        private static void CollectDetailsModelPrefab(List <AssetProperty> props, GameObject prefab, ModelImporter importer)
        {
            int totalVertices    = 0;
            int totalBlendShapes = 0;
            int totalPrimitives  = 0;

            HashSet <string> channels = null;

            if (IsGetUsedChannelsSupported)
            {
                channels = new HashSet <string>();
            }

            foreach (var mesh in AssetDatabase.LoadAllAssetsAtPath(importer.assetPath).OfType <Mesh>())
            {
                totalVertices    += mesh.vertexCount;
                totalBlendShapes += mesh.blendShapeCount;
                totalPrimitives  += GetPrimitiveCount(mesh);

                if (channels != null)
                {
                    foreach (var channel in GetUsedChannelsSanitized(mesh))
                    {
                        channels.Add(channel);
                    }
                }
            }

            if (importer.IsMeshOptimized() != null)
            {
                props.Add(AssetProperty.Create("Optimize", importer.IsMeshOptimized()));
            }
            if (importer.AreMeshVerticesOptimised() != null)
            {
                props.Add(AssetProperty.Create("OptimizeVertices", importer.AreMeshVerticesOptimised()));
            }
            if (importer.AreMeshPolygonsOptimised() != null)
            {
                props.Add(AssetProperty.Create("OptimizePolygons", importer.AreMeshPolygonsOptimised()));
            }

            props.Add(AssetProperty.Create("Vertices", totalVertices));
            props.Add(AssetProperty.Create("Triangles", totalPrimitives));
            props.Add(AssetProperty.Create("BlendShapes", totalBlendShapes));
            props.Add(AssetProperty.Create("Animations", importer.clipAnimations.Length));

            if (channels != null)
            {
                props.Add(AssetProperty.Create("VertexFormat", string.Join(",", channels.OrderBy(x => x).ToArray())));
            }
        }