Exemplo n.º 1
0
 private void RefreshList(List <string> list)
 {
     for (int i = 0; i < list.Count; ++i)
     {
         string path = EditorPath.FormatAssetPath(list[i]);
         string name = System.IO.Path.GetFileName(path);
         EditorUtility.DisplayProgressBar("获取AssetPath数据", name, (i * 1.0f) / list.Count);
         if (EditorPath.IsMeta(path))
         {
             continue;
         }
         AssetPathInfo pathInfo = AssetPathInfo.CreatePathInfo(path);
         m_pathInfoList.Add(pathInfo);
     }
     EditorUtility.ClearProgressBar();
     RefreshDataWithSelect();
 }
Exemplo n.º 2
0
        public static List <ModelInfo> GetModelInfoByDirectory(string dir)
        {
            List <ModelInfo> modelInfoList = new List <ModelInfo>();
            List <string>    list          = new List <string>();

            EditorPath.ScanDirectoryFile(dir, true, list);
            for (int i = 0; i < list.Count; ++i)
            {
                string    assetPath = EditorPath.FormatAssetPath(list[i]);
                ModelInfo modelInfo = CreateModelInfo(assetPath);
                if (modelInfo != null)
                {
                    modelInfoList.Add(modelInfo);
                }
            }

            return(modelInfoList);
        }
Exemplo n.º 3
0
        public static List <TextureInfo> GetTextureInfoByDirectory(string dir)
        {
            List <TextureInfo> texInfoList = new List <TextureInfo>();
            List <string>      list        = new List <string>();

            EditorPath.ScanDirectoryFile(dir, true, list);
            for (int i = 0; i < list.Count; ++i)
            {
                string assetPath = EditorPath.FormatAssetPath(list[i]);
                string name      = System.IO.Path.GetFileName(assetPath);
                EditorUtility.DisplayProgressBar("获取贴图数据", name, (i * 1.0f) / list.Count);
                TextureInfo texInfo = CreateTextureInfo(assetPath);
                if (texInfo != null)
                {
                    texInfoList.Add(texInfo);
                }
            }
            EditorUtility.ClearProgressBar();
            return(texInfoList);
        }
Exemplo n.º 4
0
 protected override void _RefreshList(List <string> list)
 {
     m_aniInfo = new List <AnimationInfo>();
     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.IsAnimation(path))
         {
             continue;
         }
         AnimationInfo aniInfo = AnimationInfo.CreateAnimationInfo(path);
         if (aniInfo != null)
         {
             m_aniInfo.Add(aniInfo);
         }
     }
     EditorUtility.ClearProgressBar();
     RefreshDataWithSelect();
 }
        protected override void _RefreshList(List <string> list)
        {
            m_texInfoList = new List <TextureInfo>();
            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.IsTexture(path))
                {
                    continue;
                }
                TextureInfo texInfo = TextureInfo.CreateTextureInfo(path);
                if (texInfo != null)
                {
                    m_texInfoList.Add(texInfo);
                }
            }
            EditorUtility.ClearProgressBar();

            RefreshDataWithSelect();
        }
Exemplo n.º 6
0
        public BundleImportData GetPathImportData(string path)
        {
            path = EditorPath.FormatAssetPath(path);
            path = EditorPath.NormalizePathSplash(path);
            AssetPathInfo pathInfo = AssetPathInfo.CreatePathInfo(path);

            if (pathInfo == null)
            {
                return(null);
            }

            if (pathInfo.Index >= 0 && pathInfo.Index < m_dataList.Count)
            {
                return(m_dataList[pathInfo.Index]);
            }
            for (int i = m_dataList.Count - 1; i >= 0; --i)
            {
                if (m_dataList[i].IsMatch(path))
                {
                    return(m_dataList[i]);
                }
            }
            return(null);
        }
Exemplo n.º 7
0
        public static long CalcAssetSize(string assetPath, BundleType type)
        {
            assetPath = EditorPath.FormatAssetPath(assetPath);
            assetPath = EditorPath.NormalizePathSplash(assetPath);

            long ret = 0;

            if (m_pathFileSize.TryGetValue(assetPath, out ret))
            {
                return(ret);
            }

            BundleImportData assetImportData = BundleDataControl.Instance.GetPathImportData(assetPath);

            UnityEngine.Object[] assets = null;

            switch (type)
            {
            case BundleType.Texture:
                assets = AssetDatabase.LoadAllAssetsAtPath(assetPath);
                for (int i = 0; i < assets.Length; ++i)
                {
                    if (assets[i] is Texture)
                    {
                        ret += EditorTool.GetRuntimeMemorySize(assets[i]);
                    }
                }

                break;

            case BundleType.Material:
                string[] deps = AssetDepot.GetDependenciesCache(assetPath);
                for (int i = 0; i < deps.Length; ++i)
                {
                    if (EditorPath.IsTexture(deps[i]))
                    {
                        BundleImportData data = BundleDataControl.Instance.GetPathImportData(deps[i]);
                        if (assetImportData == null || data == null || assetImportData.Index < data.Index || data.SkipData)
                        {
                            ret += EditorTool.CalculateTextureSizeBytes(deps[i]);
                        }
                    }
                }
                ret += 512;
                break;

            case BundleType.FBX:
            case BundleType.Controller:
            case BundleType.Animation:
                assets = AssetDatabase.LoadAllAssetsAtPath(assetPath);
                List <UnityEngine.Object> list = AssetFilter.FilterObjectByType(assets, type, assetPath);
                for (int i = 0; i < list.Count; ++i)
                {
                    ret += EditorTool.GetRuntimeMemorySize(list[i]);
                }
                break;

            default:
                FileInfo fileInfo = new FileInfo(assetPath);
                ret = fileInfo.Length;
                break;
            }

            for (int i = 0; assets != null && i < assets.Length; ++i)
            {
                if ((!(assets[i] is GameObject)) && (!(assets[i] is Component)))
                {
                    Resources.UnloadAsset(assets[i]);
                }
            }

            m_pathFileSize.Add(assetPath, ret);
            return(ret);
        }