Пример #1
0
        public static void CreateReport(string directory_path)
        {
            List <EAssetFileInfo> assetFiles = new List <EAssetFileInfo>(AssetBundleAnalyzeManager.FindAssetFiles().Values);

            assetFiles.Sort(SortAsset);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine(string.Format("{0},{1}",
                                        "动作名称", "占用内存"));

            int length = assetFiles.Count;

            for (int i = 0; i < length; i++)
            {
                EAssetFileInfo assetFileInfo = assetFiles[i];
                if (assetFileInfo._assetType != E_AssetType.ANIMATION_CLIP)
                {
                    continue;
                }
                List <KeyValuePair <string, System.Object> > values = assetFileInfo._propertys;

                sb.Append(string.Format("{0},{1}",
                                        assetFileInfo._assetName, values[0].Value));

                int refCount = assetFileInfo._includedBundles.Count;
                for (int j = 0; j < refCount; j++)
                {
                    sb.Append("," + assetFileInfo._includedBundles[j].AbName);
                }
                sb.AppendLine();
            }

            FileHelper.WriteTxtByFile(directory_path + "/" + ANIMATIONCLIP_NAME, sb.ToString());
        }
Пример #2
0
        public static void CreateReport(string directory_path)
        {
            List <EAssetFileInfo> asset_files = new List <EAssetFileInfo>(AssetBundleAnalyzeManager.FindAssetFiles().Values);

            asset_files.Sort(SortAsset);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine(string.Format("{0},{1},{5},{2},{3},{4}", asset_name, asset_size, asset_type, be_ref_count, ab_list, in_built));

            int length = asset_files.Count;

            for (int i = 0; i < length; i++)
            {
                EAssetFileInfo info = asset_files[i];
                sb.Append(info._assetName + "," + info.GetMemorySize() + "," + info._inBuilt + "," + info._assetType + "," + info._includedBundles.Count);
                int ref_count = info._includedBundles.Count;
                for (int j = 0; j < ref_count; j++)
                {
                    EAssetBundleFileInfo assetbundle_file = info._includedBundles[j];
                    sb.Append("," + assetbundle_file.AbName);
                }

                sb.AppendLine();
            }

            FileHelper.WriteTxtByFile(directory_path + "/" + ASSET_REPORT_NAME, sb.ToString());
        }
Пример #3
0
        public static void CreateReport(string directoryPath)
        {
            List <EAssetFileInfo> assetFiles = new List <EAssetFileInfo>(AssetBundleAnalyzeManager.FindAssetFiles().Values);

            assetFiles.Sort(SortAsset);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine(string.Format("{0},{1},{2},{3}," +
                                        "{4},{5},{6}," +
                                        "{7},{8},{9}",
                                        TEXTURE_NAME, TEXTURE_GUI, WIDTH, HEIGHT,
                                        FORMAT, MIP_MAP, READ_WRITE,
                                        SIZE, AB_COUNT, AB_FILES));

            int length = assetFiles.Count;

            for (int i = 0; i < length; i++)
            {
                EAssetFileInfo assetFileInfo = assetFiles[i];
                if (assetFileInfo._assetType != E_AssetType.TEXTURE)
                {
                    continue;
                }
                List <KeyValuePair <string, Object> > values = assetFileInfo._propertys;

                long memSize = (long)values[5].Value;
                sb.Append(string.Format("{0},{1},{2}," +
                                        "{3},{4},{5}," +
                                        "{6},{7},{8}",
                                        assetFileInfo._assetName, assetFileInfo._guid, values[0].Value, values[1].Value,
                                        values[2].Value, values[3].Value, values[4].Value,
                                        memSize, assetFileInfo._includedBundles.Count));

                int refCount = assetFileInfo._includedBundles.Count;
                for (int j = 0; j < refCount; j++)
                {
                    sb.Append("," + assetFileInfo._includedBundles[j].AbName);
                }
                sb.AppendLine();
            }

            FileHelper.WriteTxtByFile(directoryPath + "/" + REPORT_NAME, sb.ToString());
        }
Пример #4
0
 public static int SortAsset(EAssetFileInfo a, EAssetFileInfo b)
 {
     if (a == null || b == null)
     {
         return(0);
     }
     if (a._assetType < b._assetType)
     {
         return(-1);
     }
     else if (a._assetType > b._assetType)
     {
         return(1);
     }
     else
     {
         return(String.Compare(a._assetName, b._assetName, StringComparison.Ordinal));
     }
 }
Пример #5
0
        public static EAssetFileInfo FindAssetFile(long guid, long size, E_AssetType type)
        {
            if (_assetFileInfos == null)
            {
                _assetFileInfos = new Dictionary <EAssetFileInfoKey, EAssetFileInfo>();
            }

            EAssetFileInfo info;

            sKey.Guid      = guid;
            sKey.AssetType = type;
            sKey.Size      = size;
            if (!_assetFileInfos.TryGetValue(sKey, out info))
            {
                info = new EAssetFileInfo(guid);
                EAssetFileInfoKey newKey = sKey.CopyInfo();
                _assetFileInfos.Add(newKey, info);
            }
            return(info);
        }
Пример #6
0
        public static void CreateReport(string directoryPath)
        {
            List <EAssetFileInfo> assetFiles = new List <EAssetFileInfo>(AssetBundleAnalyzeManager.FindAssetFiles().Values);

            assetFiles.Sort(SortAsset);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine(string.Format("{0},{1},{2}," +
                                        "{3},{4},{5}",
                                        "网格名字", "顶点数", "面数",
                                        "子网格数", "网格压缩", "Read/Write"));

            int length = assetFiles.Count;

            for (int i = 0; i < length; i++)
            {
                EAssetFileInfo assetFileInfo = assetFiles[i];
                if (assetFileInfo._assetType != E_AssetType.MESH)
                {
                    continue;
                }
                List <KeyValuePair <string, Object> > values = assetFileInfo._propertys;

                sb.Append(string.Format("{0},{1},{2}," +
                                        "{3},{4},{5}",
                                        assetFileInfo._assetName, values[0].Value, values[1].Value,
                                        values[2].Value, values[3].Value, values[4].Value));

                int refCount = assetFileInfo._includedBundles.Count;
                for (int j = 0; j < refCount; j++)
                {
                    sb.Append("," + assetFileInfo._includedBundles[j].AbName);
                }
                sb.AppendLine();
            }

            FileHelper.WriteTxtByFile(directoryPath + "/" + MESH_NAME, sb.ToString());
        }
Пример #7
0
 /// <summary>
 /// 增加子依赖
 /// </summary>
 public void AddDepAssetFile(EAssetFileInfo assetFile)
 {
     _depAssetFiles.Add(assetFile);
 }
Пример #8
0
 public static int SortAsset(EAssetFileInfo a, EAssetFileInfo b)
 {
     return(String.CompareOrdinal(a._assetName, b._assetName));
 }
Пример #9
0
        // 分析Asset Object信息
        private static void AnalyzeAssetObject(Object assetObject, EAssetBundleFileInfo assetbundleFileInfo)
        {
            bool inBuilt = false;
            // 1.检测类型需要符合要求
            E_AssetType assetType = AssetBundleAnallyzeObject.CheckObject(assetObject, assetbundleFileInfo, ref inBuilt);

            long size = EMemorySizeHelper.GetRuntimeMemorySize(assetObject);

            if (assetType == E_AssetType.NONE)
            {
                return;
            }

            if (_inspectorMode == null)
            {
                _inspectorMode = typeof(SerializedObject).GetProperty("inspectorMode", BindingFlags.NonPublic | BindingFlags.Instance);
            }

            // 得到guid
            SerializedObject serializedObject = new SerializedObject(assetObject);

            if (_inspectorMode != null)
            {
                _inspectorMode.SetValue(serializedObject, InspectorMode.Debug, null);
            }
            SerializedProperty pathIdProp = serializedObject.FindProperty(EAssetBundleConst.LOCAL_ID_DENTFIER_IN_FILE);

            if (pathIdProp == null)
            {
                Debug.LogError("得到Id失败:" + assetbundleFileInfo.AbName + "_" + assetObject);
                return;
            }
            long guid = pathIdProp.longValue;

            List <KeyValuePair <string, System.Object> > propertys = new List <KeyValuePair <string, object> >();

            if (AssetBundleAnallyzeObject._funMap.ContainsKey(assetType))
            {
                propertys.AddRange(AssetBundleAnallyzeObject._funMap[assetType].Invoke(assetObject, serializedObject));
            }

            if (assetbundleFileInfo.IsAssetContain(guid))
            {
                Debug.LogAssertionFormat("[{0}]已经存在了[{1}]资源", assetbundleFileInfo.AbName, assetObject.name);
                serializedObject.Dispose();
                return;
            }
            if (assetType == E_AssetType.TEXTURE)
            {
                size = (long)propertys[5].Value;
            }
            EAssetFileInfo assetFileInfo = FindAssetFile(guid, size, assetType);

            assetFileInfo._memorysize = size;
            assetFileInfo.InitAsset   = true;
            assetFileInfo._assetName  = assetObject.name;
            assetFileInfo._assetType  = assetType;
            assetFileInfo._inBuilt    = inBuilt;
            assetFileInfo._propertys  = propertys;


            if (assetObject.name.Contains("11001_N") && assetType == E_AssetType.TEXTURE)
            {
                string path = AssetDatabase.GetAssetPath(assetObject);
                Debug.Log("guid:" + guid + "_" + assetbundleFileInfo.AbName + "_" + EMemorySizeHelper.GetRuntimeMemorySize(assetObject) + "_" + size + "_" + path);
            }

            // AssetBundle包含了Asset资源
            assetbundleFileInfo.AddDepAssetFile(assetFileInfo);
            // Asset被指定的AssetBundle引用
            assetFileInfo.AddParent(assetbundleFileInfo);
            serializedObject.Dispose();

            AssetRepeatReport.AddAssetFile(assetFileInfo);
        }