Example #1
0
        public static ModelInfo CreateModelInfo(string assetPath)
        {
            if (!EditorPath.IsModel(assetPath))
            {
                return(null);
            }

            ModelInfo tInfo = null;

            if (!m_dictModelInfo.TryGetValue(assetPath, out tInfo))
            {
                tInfo = new ModelInfo();
                m_dictModelInfo.Add(assetPath, tInfo);
            }
            ModelImporter tImport = AssetImporter.GetAtPath(assetPath) as ModelImporter;
            Mesh          mesh    = AssetDatabase.LoadAssetAtPath <Mesh>(assetPath);

            if (tImport == null || mesh == null)
            {
                return(null);
            }

            tInfo.Path            = assetPath;
            tInfo.ReadWriteEnable = tImport.isReadable;
            tInfo.OptimizeMesh    = tImport.optimizeMesh;
            tInfo.ImportMaterials = tImport.importMaterials;
            tInfo.ImportAnimation = tImport.importAnimation;
            tInfo.MeshCompression = tImport.meshCompression;

            tInfo.bHasUV        = mesh.uv != null && mesh.uv.Length != 0;
            tInfo.bHasUV2       = mesh.uv2 != null && mesh.uv2.Length != 0;
            tInfo.bHasUV3       = mesh.uv3 != null && mesh.uv3.Length != 0;
            tInfo.bHasUV4       = mesh.uv4 != null && mesh.uv4.Length != 0;
            tInfo.bHasColor     = mesh.colors != null && mesh.colors.Length != 0;
            tInfo.bHasNormal    = mesh.normals != null && mesh.normals.Length != 0;
            tInfo.bHasTangent   = mesh.tangents != null && mesh.tangents.Length != 0;
            tInfo.vertexCount   = mesh.vertexCount;
            tInfo.triangleCount = mesh.triangles.Length / 3;

            tInfo.MemSize = EditorTool.CalculateModelSizeBytes(assetPath);

            if (m_loadCount % 256 == 0)
            {
                Resources.UnloadUnusedAssets();
            }

            return(tInfo);
        }
Example #2
0
 protected override void _RefreshList(List <string> list)
 {
     m_modelInfo = new List <ModelInfo>();
     for (int i = 0; i < list.Count; ++i)
     {
         string path = EditorPath.FormatAssetPath(list[i]);
         string name = System.IO.Path.GetFileName(path);
         EditorUtility.DisplayProgressBar("获取模型数据", name, (i * 1.0f) / list.Count);
         if (!EditorPath.IsModel(path))
         {
             continue;
         }
         ModelInfo modelInfo = ModelInfo.CreateModelInfo(path);
         if (modelInfo != null)
         {
             m_modelInfo.Add(modelInfo);
         }
     }
     EditorUtility.ClearProgressBar();
     RefreshDataWithSelect();
 }
Example #3
0
 public override bool IsMatch(string path)
 {
     return(EditorPath.IsModel(path) && base.IsMatch(path));
 }