public void Add(AnalyzeObjectInfo item)
        {
            List <AnalyzeObjectInfo> list = GetList(item.type);

            list.Add(item);
            guidDict.Add(item.guid, item);
        }
Esempio n. 2
0
        public static void Report(AnalyzeProjectInfo project, List <string> roots)
        {
            List <string> files = new List <string>();

            string[] arr;
            foreach (string root in roots)
            {
                if (!Directory.Exists(root))
                {
                    continue;
                }
                arr = Directory.GetFiles(root, "*.Prefab", SearchOption.AllDirectories);
                files.AddRange(arr);
            }

            for (int i = 0; i < files.Count; i++)
            {
                string path = files[i];
                Object o    = AssetDatabase.LoadAssetAtPath(path, typeof(Object));
                string guid = AssetDatabase.AssetPathToGUID(path);

                AnalyzeObjectInfo objectInfo = project.Get(guid);

                if (objectInfo == null)
                {
                    objectInfo          = new AnalyzeObjectInfo();
                    objectInfo.guid     = guid;
                    objectInfo.path     = path;
                    objectInfo.type     = o.GetType();
                    objectInfo.fileInfo = AnalyzeFileAsset.Generate(o);
                    AnalyzeFileInfo f = objectInfo.fileInfo;

                    objectInfo.propertys = new List <KeyValuePair <string, object> >();
                    objectInfo.propertys.Add(new KeyValuePair <string, object>(AnalyzePropertys.MaterialCount, f.MaterialCount));
                    objectInfo.propertys.Add(new KeyValuePair <string, object>(AnalyzePropertys.Texture2DCount, f.Texture2DCount));
                    objectInfo.propertys.Add(new KeyValuePair <string, object>(AnalyzePropertys.TotalTriangleCount, f.TotalTriangleCount));
                    objectInfo.propertys.Add(new KeyValuePair <string, object>(AnalyzePropertys.TotalVertexCount, f.TotalVertexCount));
                    objectInfo.propertys.Add(new KeyValuePair <string, object>(AnalyzePropertys.BonesCount, f.BonesCount));
                    objectInfo.propertys.Add(new KeyValuePair <string, object>(AnalyzePropertys.ParticleSystemCount, f.ParticleSystemCount));
                    objectInfo.propertys.Add(new KeyValuePair <string, object>(AnalyzePropertys.TotalForecastParticleCount, f.TotalForecastParticleCount));
                    objectInfo.propertys.Add(new KeyValuePair <string, object>(AnalyzePropertys.TotalForecastTrianglesCount, f.TotalForecastTrianglesCount));
                    objectInfo.propertys.Add(new KeyValuePair <string, object>(AnalyzePropertys.MeshFilterCount, f.MeshFilterCount));
                    objectInfo.propertys.Add(new KeyValuePair <string, object>(AnalyzePropertys.SkinnedMeshRendererCount, f.SkinnedMeshRendererCount));
                    objectInfo.propertys.Add(new KeyValuePair <string, object>(AnalyzePropertys.MeshRendererCount, f.MeshRendererCount));
                    objectInfo.propertys.Add(new KeyValuePair <string, object>(AnalyzePropertys.AnimatorCount, f.AnimatorCount));
                    objectInfo.propertys.Add(new KeyValuePair <string, object>(AnalyzePropertys.TransformCount, f.TransformCount));
                    objectInfo.propertys.Add(new KeyValuePair <string, object>(AnalyzePropertys.ObjectCount, f.ObjectCount));

                    project.Add(objectInfo);
                }
            }
        }
        public static void Report(AnalyzeProjectInfo project)
        {
            string[] guids = AssetDatabase.FindAssets("t:texture2D", null);

            Type type = typeof(Texture2D);

            foreach (string guid in guids)
            {
                AnalyzeObjectInfo objectInfo = project.Get(guid);
                if (objectInfo == null)
                {
                    objectInfo      = new AnalyzeObjectInfo();
                    objectInfo.guid = guid;
                    objectInfo.type = type;
                    objectInfo.path = AssetDatabase.GUIDToAssetPath(guid);



                    var importer = AssetImporter.GetAtPath(objectInfo.path) as TextureImporter;
                    if (importer == null)
                    {
                        continue;
                    }

                    string format = "未知";
                    int    w, h;
                    var    tex = GetTextureSize(importer, out w, out h) as Texture2D;
                    if (tex != null)
                    {
                        format = tex.format.ToString();
                    }

                    objectInfo.propertys = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(AnalyzePropertys.Width, w),
                        new KeyValuePair <string, object>(AnalyzePropertys.Height, h),
                        new KeyValuePair <string, object>(AnalyzePropertys.IsPow2Size, IsPow2Size(w, h)),
                        new KeyValuePair <string, object>(AnalyzePropertys.MaxTextureSize, importer.maxTextureSize),
                        new KeyValuePair <string, object>(AnalyzePropertys.ReadWrite, importer.isReadable),
                        new KeyValuePair <string, object>(AnalyzePropertys.MiniMap, importer.mipmapEnabled),
                        new KeyValuePair <string, object>(AnalyzePropertys.TextureFormat, format),
                        new KeyValuePair <string, object>(AnalyzePropertys.TextureCompression, importer.textureCompression.ToString()),
                        new KeyValuePair <string, object>(AnalyzePropertys.SpriteImportMode, importer.spriteImportMode.ToString()),
                    };

                    project.Add(objectInfo);
                }
            }
        }
Esempio n. 4
0
        public static void Report(AnalyzeProjectInfo project)
        {
            string[] guids = AssetDatabase.FindAssets("t:Mesh", null);

            Type type = typeof(Mesh);

            foreach (string guid in guids)
            {
                AnalyzeObjectInfo objectInfo = project.Get(guid);
                if (objectInfo == null)
                {
                    objectInfo      = new AnalyzeObjectInfo();
                    objectInfo.guid = guid;
                    objectInfo.type = type;
                    objectInfo.path = AssetDatabase.GUIDToAssetPath(guid);



                    var importer = AssetImporter.GetAtPath(objectInfo.path) as ModelImporter;
                    if (importer == null)
                    {
                        continue;
                    }

                    var mesh = AssetDatabase.LoadAssetAtPath <Mesh>(objectInfo.path);

                    objectInfo.propertys = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(AnalyzePropertys.VertexCount, mesh.vertexCount),
                        new KeyValuePair <string, object>(AnalyzePropertys.TriangleCount, (mesh.triangles.Length / 3f)),
                        new KeyValuePair <string, object>(AnalyzePropertys.SubMeshCount, mesh.subMeshCount),
                        new KeyValuePair <string, object>(AnalyzePropertys.ScaleFactor, importer.globalScale),
                        new KeyValuePair <string, object>(AnalyzePropertys.UseFileUnits, importer.useFileUnits),
                        new KeyValuePair <string, object>(AnalyzePropertys.FileScale, importer.fileScale),
                        new KeyValuePair <string, object>(AnalyzePropertys.MeshCompression, importer.meshCompression.ToString()),
                        new KeyValuePair <string, object>(AnalyzePropertys.ReadWrite, importer.isReadable),
                        new KeyValuePair <string, object>(AnalyzePropertys.OptimizeMesh, importer.optimizeMesh),
                        new KeyValuePair <string, object>(AnalyzePropertys.OptimizeGameObjects, importer.optimizeGameObjects),
                        new KeyValuePair <string, object>(AnalyzePropertys.GenerateCollider, importer.addCollider),
                        new KeyValuePair <string, object>(AnalyzePropertys.ImportBlendShapes, importer.importBlendShapes),
                        new KeyValuePair <string, object>(AnalyzePropertys.ImportMaterials, importer.importMaterials),
                        new KeyValuePair <string, object>(AnalyzePropertys.TransformPathsCount, importer.transformPaths.Length),
                        new KeyValuePair <string, object>(AnalyzePropertys.ExtraExposedTransformPathsCount, importer.extraExposedTransformPaths.Length),
                    };

                    project.Add(objectInfo);
                }
            }
        }