Esempio n. 1
0
        private void ReportAudio(StringBuilder sb, AudioImporter importer)
        {
            /// common
            sb.Append("{");
            AssetsReporterUtils.AddJsonObject(sb, "path", importer.assetPath).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "forceToMono", importer.forceToMono).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "loadInBackground", importer.loadInBackground).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "preloadAudioData", importer.preloadAudioData).Append(",");
            // platform setting
            AudioImporterSampleSettings setting = importer.defaultSampleSettings;

            if (!string.IsNullOrEmpty(platform) && importer.ContainsSampleSettingsOverride(platform))
            {
                setting = importer.GetOverrideSampleSettings(platform);
            }
            AssetsReporterUtils.AddJsonObject(sb, "loadType", setting.loadType.ToString()).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "compressionFormat", setting.compressionFormat.ToString()).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "sampleRateSetting", setting.sampleRateSetting.ToString()).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "sampleRateOverride", setting.sampleRateOverride.ToString());
            sb.Append("}");

            AssetsReporterUtils.AddCountDictionary(this.loadTypeSet, setting.loadType);
            AssetsReporterUtils.AddCountDictionary(this.ratingSet, setting.sampleRateOverride);
            AssetsReporterUtils.AddCountDictionary(this.compressSet, setting.compressionFormat);
        }
Esempio n. 2
0
        public static string GetWebVisibleTexturePreview(TextureImporter importer, Texture2D tex, bool createFlag)
        {
            if (importer == null || tex == null)
            {
                return("");
            }
            string guid = AssetDatabase.AssetPathToGUID(importer.assetPath);
            string file = guid + ".png";

            if (!createFlag)
            {
                return(file);
            }


            var           backupActive  = RenderTexture.active;
            RenderTexture renderTexture = new RenderTexture(tex.width, tex.height, 0);
            CommandBuffer cmd           = new CommandBuffer();

            cmd.Blit(tex, renderTexture);
            Graphics.ExecuteCommandBuffer(cmd);
            cmd.Dispose();

            RenderTexture.active = renderTexture;
            var saveTex = new Texture2D(tex.width, tex.height, TextureFormat.RGBA32, false);

            saveTex.ReadPixels(new Rect(0, 0, tex.width, tex.height), 0, 0);
            AssetsReporterUtils.SaveTexture2d(AssetsReporterUtils.PreviewDir + file, saveTex);

            RenderTexture.active = backupActive;
            renderTexture.Release();

            return(file);
        }
Esempio n. 3
0
        public static string GetAssetPreview(AssetImporter importer, UnityEngine.Object obj, bool createFlag)
        {
            if (importer == null || obj == null)
            {
                return("");
            }
            string guid = AssetDatabase.AssetPathToGUID(importer.assetPath);
            string file = guid + ".png";

            if (!createFlag)
            {
                return(file);
            }

            //					var gmo = GameObject.Instantiate(obj);
            var tex = AssetPreview.GetAssetPreview(obj);

            tex = AssetPreview.GetAssetPreview(obj);
            for (int i = 0; i < 100; ++i)
            {
                if (obj != null && tex == null)
                {
                    tex = AssetPreview.GetAssetPreview(obj);
                    System.Threading.Thread.Sleep(10);
                }
            }
            if (tex != null)
            {
                AssetsReporterUtils.SaveTexture2d(AssetsReporterUtils.PreviewDir + file, tex);
                tex = null;
            }
            return(file);
        }
        private void ReportDependsAssetBundle(StringBuilder sb)
        {
            bool isFirst = true;

            sb.Append("depends:[");
            List <AssetBundleIdentify> list = new List <AssetBundleIdentify>(this.dependBundle);

            list.Sort((a, b) =>
            {
                int tmp = a.importerType.CompareTo(b.importerType);
                if (tmp != 0)
                {
                    return(tmp);
                }
                return(a.file.CompareTo(b.file));
            });
            foreach (var d in list)
            {
                if (isFirst)
                {
                    isFirst = false;
                }
                else
                {
                    sb.Append(",");
                }
                sb.Append("{");
                AssetsReporterUtils.AddJsonObject(sb, "file", d.file).Append(",");
                AssetsReporterUtils.AddJsonObject(sb, "name", d.name).Append(",");
                AssetsReporterUtils.AddJsonObject(sb, "valiant", d.valiant).Append(",");
                AssetsReporterUtils.AddJsonObject(sb, "importerType", d.importerType.Replace("Importer", ""));
                sb.Append("}");
            }
            sb.Append("]");
        }
Esempio n. 5
0
        public void ReportScenes(string reportPath)
        {
            try
            {
                var sb = new StringBuilder(1024 * 1024);
                sb.Append("g_scene_report = [");
                var scenePathList = GetAllScenePath();

                bool isFirst = true;
                foreach (var scenePath in scenePathList)
                {
                    if (isFirst)
                    {
                        isFirst = false;
                    }
                    else
                    {
                        sb.Append(",");
                    }
                    ReportSceneAtPath(sb, scenePath);
                }

                sb.Append("];");
                File.WriteAllText(reportPath, sb.ToString());
                AssetsReporterUtils.AddCurrenTimeVar(sb);
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
        }
        private void ReportDependsAssets(StringBuilder sb)
        {
            foreach (var asset in this.resourceAssetList)
            {
                this.dependSet.Remove(asset);
            }
            bool isFirst = true;

            sb.Append("g_resources_depends=[");
            foreach (var depend in dependSet)
            {
                if (isFirst)
                {
                    isFirst = false;
                }
                else
                {
                    sb.Append(",");
                }
                sb.Append("\n");
                sb.Append("{");
                AssetsReporterUtils.AddJsonObject(sb, "path", depend).Append(",");
                AssetsReporterUtils.AddJsonObject(sb, "type", this.GetFileType(depend).ToString());
                sb.Append("}");
            }
            sb.Append("];");
        }
Esempio n. 7
0
        private void ReportModelAnimationClips(StringBuilder sb, ModelImporterClipAnimation[] clipAnimations)
        {
            if (clipAnimations == null)
            {
                AssetsReporterUtils.AddJsonObjectArray(sb, "animationClips", null);
            }
            bool isFirst = true;

            sb.Append("animationClips:[");
            for (int i = 0; i < clipAnimations.Length; ++i)
            {
                if (isFirst)
                {
                    isFirst = false;
                }
                else
                {
                    sb.Append(",");
                }
                sb.Append("{");
                AssetsReporterUtils.AddJsonObject(sb, "name", clipAnimations[i].name).Append(",");
                AssetsReporterUtils.AddJsonObject(sb, "firstFrame", clipAnimations[i].firstFrame).Append(",");
                AssetsReporterUtils.AddJsonObject(sb, "lastFrame", clipAnimations[i].lastFrame).Append(",");
                AssetsReporterUtils.AddJsonObject(sb, "wrapMode", clipAnimations[i].wrapMode.ToString()).Append(",");
                AssetsReporterUtils.AddJsonObject(sb, "loop", clipAnimations[i].loop);
                sb.Append("}");
            }
            sb.Append("]");
        }
        void OnGUI()
        {
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);


            OnGUISelectLanguage();

            EditorGUILayout.LabelField("Platform Select");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.Width(Space));
            currentTarget = EditorGUILayout.Popup(currentTarget, targetList);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
            OnGUIExcludeList();
            EditorGUILayout.Space();
            // all
            OnGUIReportGroup("All Report",
                             () =>
            {
                TextureReporter.CreateReport(targetList[currentTarget], excludeList);
                ModelReporter.CreateReport(excludeList);
                AudioReporter.CreateReport(targetList[currentTarget], excludeList);
                AssetBundleReporter.CreateReport(false);
                ResourcesReporter.CreateReport();
                SceneReporter.CreateReport(excludeList);
            },
                             () =>
            {
                AssetsReporterUtils.OpenURL(Path.Combine("AssetsReporter", "index.html"));
            });

            EditorGUILayout.Space();
            // Texture
            OnGUIReportGroup("Texture Report",
                             () => { TextureReporter.CreateReport(targetList[currentTarget], excludeList); },
                             TextureReporter.OpenReport);
            // Audios
            OnGUIReportGroup("Audio Report",
                             () => { AudioReporter.CreateReport(targetList[currentTarget], excludeList); },
                             AudioReporter.OpenReport);
            // models
            OnGUIReportGroup("Model Report",
                             () => { ModelReporter.CreateReport(excludeList); },
                             ModelReporter.OpenReport);
            // AssetBundles
            OnGUIReportGroup("AssetBundle Report",
                             () => { AssetBundleReporter.CreateReport(true); },
                             AssetBundleReporter.OpenReport);
            // Resources
            OnGUIReportGroup("Resources Report", ResourcesReporter.CreateReport, ResourcesReporter.OpenReport);
            // Scenes
            OnGUIReportGroup("Scene Report",
                             () => { SceneReporter.CreateReport(excludeList); },
                             SceneReporter.OpenReport);

            EditorGUILayout.EndScrollView();
        }
Esempio n. 9
0
        public void ReportModel(string reportPath)
        {
            try
            {
                scaleSet        = new Dictionary <float, int>();
                rigSet          = new Dictionary <ModelImporterAnimationType, int>();
                sourceAvatarSet = new Dictionary <string, int>();
                if (isPreviewImage)
                {
                    AssetsReporterUtils.CreatePreviewDir();
                }

                var  guids   = AssetDatabase.FindAssets("t:model", null);
                var  sb      = new StringBuilder(1024 * 1024);
                int  idx     = 0;
                bool isFirst = true;
                AssetsReporterUtils.AddCurrenTimeVar(sb);
                sb.Append("g_model_report = [");
                foreach (var guid in guids)
                {
                    string path          = AssetDatabase.GUIDToAssetPath(guid);
                    var    modelImporter = AssetImporter.GetAtPath(path) as ModelImporter;
                    if (modelImporter == null || AssetsReporterUtils.IsPathMatch(path, excludeList))
                    {
                        continue;
                    }
                    if (isFirst)
                    {
                        isFirst = false;
                    }
                    else
                    {
                        sb.Append(",");
                    }
                    ReportModel(sb, modelImporter);

                    sb.Append("\n");
                    EditorUtility.DisplayProgressBar("Progress", path, (float)idx / (float)guids.Length);
                    ++idx;
                }
                sb.Append("];");
                AssetsReporterUtils.AddCountVarObject(sb, "g_model_rig_list", rigSet);
                AssetsReporterUtils.AddCountVarObject(sb, "g_model_scale_list", scaleSet);
                AssetsReporterUtils.AddCountVarObject(sb, "g_model_avatar_list", sourceAvatarSet);
                AssetsReporterUtils.AddPlatformVar(sb, "");
                File.WriteAllText(reportPath, sb.ToString());
            }
            finally
            {
                EditorUtility.ClearProgressBar();
            }
        }
Esempio n. 10
0
 private static void AddToConpoenentCountDictionary(Dictionary <string, int> cntDict, Component[] components)
 {
     if (components == null)
     {
         return;
     }
     foreach (var component in components)
     {
         if (component != null)
         {
             AssetsReporterUtils.AddCountDictionary(cntDict, component.GetType().ToString());
         }
     }
 }
Esempio n. 11
0
        public void ReportTexture(string reportPath)
        {
            try
            {
                AssetsReporterUtils.CreatePreviewDir();

                this.textureTypeSet   = new Dictionary <TextureImporterType, int>();
                this.textureFormatSet = new Dictionary <TextureImporterFormat, int>();
                this.spriteTagSet     = new Dictionary <string, int>();
                var  guids   = AssetDatabase.FindAssets("t:texture2D", null);
                var  sb      = new StringBuilder(1024 * 1024);
                int  idx     = 0;
                bool isFirst = true;
                AssetsReporterUtils.AddCurrenTimeVar(sb);
                sb.Append("g_texture_report = [");
                foreach (var guid in guids)
                {
                    string path            = AssetDatabase.GUIDToAssetPath(guid);
                    var    textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
                    if (textureImporter == null || AssetsReporterUtils.IsPathMatch(path, excludeList))
                    {
                        continue;
                    }
                    if (isFirst)
                    {
                        isFirst = false;
                    }
                    else
                    {
                        sb.Append(",");
                    }
                    ReportTexture(sb, textureImporter);

                    sb.Append("\n");
                    EditorUtility.DisplayProgressBar("Progress", path, (float)idx / (float)guids.Length);
                    ++idx;
                }
                sb.Append("];");
                AssetsReporterUtils.AddCountVarObject(sb, "g_texture_format_list", textureFormatSet);
                AssetsReporterUtils.AddCountVarObject(sb, "g_texture_type_list", textureTypeSet);
                AssetsReporterUtils.AddCountVarObject(sb, "g_texture_spriteTag_list", spriteTagSet);
                AssetsReporterUtils.AddPlatformVar(sb, this.platform);
                File.WriteAllText(reportPath, sb.ToString());
            }
            finally
            {
                EditorUtility.ClearProgressBar();
            }
        }
Esempio n. 12
0
        public void ReportAudio(string reportPath)
        {
            try
            {
                this.ratingSet   = new Dictionary <uint, int>();
                this.compressSet = new Dictionary <AudioCompressionFormat, int>();
                this.loadTypeSet = new Dictionary <AudioClipLoadType, int>();

                StringBuilder sb = new StringBuilder(1024 * 1024);
                AssetsReporterUtils.AddCurrenTimeVar(sb);
                int  idx     = 0;
                bool isFirst = true;
                var  guids   = AssetDatabase.FindAssets("t:audioclip");
                sb.Append("g_audio_report=[");
                foreach (var guid in guids)
                {
                    string path          = AssetDatabase.GUIDToAssetPath(guid);
                    var    audioImporter = AssetImporter.GetAtPath(path) as AudioImporter;
                    if (audioImporter == null || AssetsReporterUtils.IsPathMatch(path, excludeList))
                    {
                        continue;
                    }
                    if (isFirst)
                    {
                        isFirst = false;
                    }
                    else
                    {
                        sb.Append(',');
                    }
                    ReportAudio(sb, audioImporter);
                    ++idx;
                    EditorUtility.DisplayProgressBar("Progress", path, (float)idx / (float)guids.Length);
                }
                sb.Append("];");
                AssetsReporterUtils.AddCountVarObject(sb, "g_audio_rating_list", this.ratingSet);
                AssetsReporterUtils.AddCountVarObject(sb, "g_audio_loadtype_list", this.loadTypeSet);
                AssetsReporterUtils.AddCountVarObject(sb, "g_audio_compress_list", this.compressSet);
                AssetsReporterUtils.AddPlatformVar(sb, this.platform);
                File.WriteAllText(reportPath, sb.ToString());
            }
            finally
            {
                EditorUtility.ClearProgressBar();
            }
        }
        private void ReportOneResource(StringBuilder sb, string assetPath)
        {
            var depends = AssetDatabase.GetDependencies(new string[] { assetPath });

            Type type = this.GetFileType(assetPath);

            AssetsReporterUtils.AddCountDictionary(this.typeDict, type);

            sb.Append("{");
            AssetsReporterUtils.AddJsonObject(sb, "path", assetPath).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "type", type.ToString()).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "parentDir", this.GetParentDirectory(assetPath)).Append(",");

            sb.Append("depends:[");
            bool isFirst = true;

            foreach (var d in depends)
            {
                if (d == assetPath)
                {
                    continue;
                }
                if (isFirst)
                {
                    isFirst = false;
                }
                else
                {
                    sb.Append(",");
                }
                sb.Append("{");
                AssetsReporterUtils.AddJsonObject(sb, "path", d).Append(",");
                AssetsReporterUtils.AddJsonObject(sb, "type", this.GetFileType(d).ToString());
                sb.Append("}");
            }
            sb.Append("]");
            foreach (var depend in depends)
            {
                if (!this.dependSet.Contains(depend))
                {
                    this.dependSet.Add(depend);
                }
            }
            sb.Append("}");
        }
Esempio n. 14
0
        private StringBuilder ReportSceneDependAssets(StringBuilder sb, string scenePath)
        {
            var depends = AssetDatabase.GetDependencies(scenePath, true);

            sb.Append("depends:[");
            if (depends != null)
            {
                bool firstFlag = true;
                foreach (var depend in depends)
                {
                    if (depend == null)
                    {
                        continue;
                    }
                    if (firstFlag)
                    {
                        firstFlag = false;
                    }
                    else
                    {
                        sb.Append(',');
                    }
                    var importer = AssetImporter.GetAtPath(depend);
                    var obj      = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(importer.assetPath);
                    sb.Append("{");
                    AssetsReporterUtils.AddJsonObject(sb, "path", depend).Append(",");
                    AssetsReporterUtils.AddJsonObject(sb, "importer", importer.GetType().ToString());

                    if (obj != null)
                    {
                        sb.Append(",");
                        AssetsReporterUtils.AddJsonObject(sb, "type", obj.GetType().ToString());
                    }
                    else
                    {
                        Debug.Log("loaderror " + depend + "::" + importer.name);
                    }
                    obj = null;
                    sb.Append("}\n");
                }
            }
            Resources.UnloadUnusedAssets();
            sb.Append("]\n");
            return(sb);
        }
 private void OnGUIReportGroup(string groupName, Action reportAct, Action openAct)
 {
     EditorGUILayout.LabelField(groupName);
     EditorGUILayout.BeginHorizontal();
     EditorGUILayout.LabelField("", GUILayout.Width(Space));
     if (GUILayout.Button("Report", GUILayout.Width(100)))
     {
         SaveExcludeList();
         AssetsReporterUtils.WriteReportLanguage(languages[this.selectLanguageIdx].languageCode);
         reportAct();
         openAct();
     }
     if (GUILayout.Button("Open", GUILayout.Width(100)))
     {
         openAct();
     }
     EditorGUILayout.EndHorizontal();
 }
Esempio n. 16
0
        private void ReportSceneAtPath(StringBuilder sb, string scenePath)
        {
            var scene = EditorSceneManager.OpenScene(scenePath);

            sb.Append("{");
            AssetsReporterUtils.AddJsonObject(sb, "buildIndex", scene.buildIndex).Append(",\n");
            AssetsReporterUtils.AddJsonObject(sb, "path", scenePath).Append(",\n");
            AssetsReporterUtils.AddJsonObject(sb, "sceneName", scene.name).Append(",\n");
            AssetsReporterUtils.AddJsonObject(sb, "rootCount", scene.rootCount).Append(",\n");

            ReportSceneDependAssets(sb, scenePath);
            sb.Append(",");

            var rootObjects = scene.GetRootGameObjects();

            int allGameObjectCount        = 0;
            int allComponentCount         = 0;
            int allMonoBehaviourCount     = 0;
            var componentsCountDictionary = new Dictionary <string, int>(1024);

            foreach (var rootObj in rootObjects)
            {
                allGameObjectCount += CountChildTransform(rootObj.transform);
                var childComponents    = rootObj.GetComponentsInChildren <Component>();
                var childMonoBehaviour = rootObj.GetComponentsInChildren <MonoBehaviour>();
                if (childComponents != null)
                {
                    allComponentCount += childComponents.Length;
                }
                if (childMonoBehaviour != null)
                {
                    allMonoBehaviourCount += childMonoBehaviour.Length;
                }
                AddToConpoenentCountDictionary(componentsCountDictionary, childComponents);
            }
            AssetsReporterUtils.AddJsonObject(sb, "allGameObjects", allGameObjectCount).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "allComponents", allComponentCount).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "allMonoBehaviour", allMonoBehaviourCount).Append(",");
            AssetsReporterUtils.AddJsonToContDictionary(sb, "componentCount", componentsCountDictionary);
            sb.Append("}");
        }
        public void Report(bool thumnailFlag)
        {
            try
            {
                this.createThumnailPreview = thumnailFlag;
                int           idx = 0;
                StringBuilder sb  = new StringBuilder();

                string[] abnames = AssetDatabase.GetAllAssetBundleNames();
                bool     isFirst = true;
                AssetsReporterUtils.AddCurrenTimeVar(sb);
                AssetsReporterUtils.AddPlatformVar(sb, "");

                sb.Append("g_ab_report=[");
                foreach (var abname in abnames)
                {
                    string[] paths = AssetDatabase.GetAssetPathsFromAssetBundle(abname);
                    if (paths == null || paths.Length == 0)
                    {
                        continue;
                    }
                    if (isFirst)
                    {
                        isFirst = false;
                    }
                    else
                    {
                        sb.Append(",");
                    }
                    CreateAssetData(sb, abname, paths);
                    ++idx;
                    EditorUtility.DisplayProgressBar("AssetBundleReport", abname, idx / (float)abnames.Length);
                }
                sb.Append("];");
                File.WriteAllText(AssetsReporterUtils.ResultDir + "report_ab.js", sb.ToString());
            }
            finally
            {
                EditorUtility.ClearProgressBar();
            }
        }
        public void ReportResources(string reportPath)
        {
            try
            {
                var  sb      = new StringBuilder(1024 * 1024);
                bool isFirst = true;
                AssetsReporterUtils.AddCurrenTimeVar(sb);
                sb.Append("g_resources_report = [");
                var allAssetPath = AssetDatabase.GetAllAssetPaths();
                foreach (var assetPath in allAssetPath)
                {
                    if (!assetPath.Contains("/Resources/"))
                    {
                        continue;
                    }
                    if (isFirst)
                    {
                        isFirst = false;
                    }
                    else
                    {
                        sb.Append(',');
                    }
                    sb.Append("\n");
                    this.resourceAssetList.Add(assetPath);
                    this.ReportOneResource(sb, assetPath);
                    this.SetParentDictionarySet(assetPath);
                }
                sb.Append("];\n");
                this.ReportDependsAssets(sb);

                AssetsReporterUtils.AddCountVarObject(sb, "g_resources_type_list", this.typeDict);
                AssetsReporterUtils.AddCountVarObject(sb, "g_resources_parent_dir_list", this.parentDirDict);
                AssetsReporterUtils.AddPlatformVar(sb, "");
                File.WriteAllText(reportPath, sb.ToString());
            }
            finally
            {
                EditorUtility.ClearProgressBar();
            }
        }
Esempio n. 19
0
        private void ReportModel(StringBuilder sb, ModelImporter importer)
        {
            sb.Append("{");
            AssetsReporterUtils.AddJsonObject(sb, "path", importer.assetPath).Append(",");
            if (this.isPreviewImage)
            {
                var obj = AssetDatabase.LoadAssetAtPath <GameObject>(importer.assetPath);

                string preview = AssetsReporterUtils.GetAssetPreview(importer, obj, true);
                AssetsReporterUtils.AddJsonObject(sb, "preview", preview).Append(",");

                AssetsReporterUtils.AddJsonObject(sb, "vertexNum", AssetsReporterUtils.GetPolygonNum(obj)).Append(",");
            }
            AssetsReporterUtils.AddJsonObject(sb, "isReadable", importer.isReadable).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "scaleFactor", importer.globalScale).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "meshCompression", importer.meshCompression.ToString()).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "generateCollider", importer.addCollider).Append(",");
#if UNITY_2020_2_OR_NEWER
            AssetsReporterUtils.AddJsonObject(sb, "materialImportMode", importer.materialImportMode.ToString()).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "optimizeMeshPolygons", importer.optimizeMeshPolygons).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "optimizeMeshVertices", importer.optimizeMeshVertices).Append(",");
            // 互換性
            AssetsReporterUtils.AddJsonObject(sb, "optimizeMesh", importer.optimizeMeshVertices | importer.optimizeMeshPolygons).Append(",");
#else
            AssetsReporterUtils.AddJsonObject(sb, "importMaterials", importer.importMaterials).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "optimizeMesh", importer.optimizeMesh).Append(",");
#endif
#if UNITY_5_4_OR_NEWER
            AssetsReporterUtils.AddJsonObject(sb, "normalMode", importer.importNormals.ToString()).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "tangentMode", importer.importTangents.ToString()).Append(",");
#else
            AssetsReporterUtils.AddJsonObject(sb, "normalMode", importer.normalImportMode.ToString()).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "tangentMode", importer.tangentImportMode.ToString()).Append(",");
#endif
            AssetsReporterUtils.AddJsonObject(sb, "importBlendShapes", importer.importBlendShapes).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "objectNum", importer.transformPaths.Length).Append(",");
            // rig
            AssetsReporterUtils.AddJsonObject(sb, "animationType", importer.animationType.ToString()).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "generateAnimations", importer.generateAnimations.ToString()).Append(",");
            string srcAvatar = GetAvatarName(importer.animationType, importer.sourceAvatar);
            AssetsReporterUtils.AddJsonObject(sb, "sourceAvatar", srcAvatar).Append(",");
            // animation
            AssetsReporterUtils.AddJsonObject(sb, "importAnimation", importer.importAnimation).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "animationCompression", importer.animationCompression.ToString()).Append(",");
            if (importer.clipAnimations != null && importer.clipAnimations.Length > 0)
            {
                ReportModelAnimationClips(sb, importer.clipAnimations);
            }
            else
            {
                ReportModelAnimationClips(sb, importer.defaultClipAnimations);
            }
            //
            AssetsReporterUtils.AddCountDictionary(rigSet, importer.animationType);
            AssetsReporterUtils.AddCountDictionary(scaleSet, importer.globalScale);
            if (!string.IsNullOrEmpty(srcAvatar))
            {
                AssetsReporterUtils.AddCountDictionary(sourceAvatarSet, srcAvatar);
            }
            sb.Append("}");
        }
Esempio n. 20
0
 public static void OpenReport()
 {
     AssetsReporterUtils.OpenURL(Path.Combine("AssetsReporter", "report_scene.html"));
 }
 public static void Create()
 {
     AssetsReporterUtils.UnzipPackageData();
     EditorWindow.GetWindow <AssetsReporterWindow>();
 }
        private void CreateAssetData(StringBuilder sb, string abname, string[] paths)
        {
            bool isFirst = true;

            sb.Append("{");
            AssetsReporterUtils.AddJsonObject(sb, "abname", abname).Append(",");
            this.ClearDependsAssetBundle();
            sb.Append("files:[");
            foreach (var path in paths)
            {
                if (isFirst)
                {
                    isFirst = false;
                }
                else
                {
                    sb.Append(",");
                }
                sb.Append("{");
                AssetsReporterUtils.AddJsonObject(sb, "path", path).Append(",");

                var depends = AssetDatabase.GetDependencies(new string[] { path });
                System.Array.Sort(depends);
                this.AddDependsAssetBundle(depends);
                AssetsReporterUtils.AddJsonObjectArrayWithout(sb, "depends", depends, path);
                System.Array.Sort <string>(depends);

                UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(path);
                if (obj != null)
                {
                    sb.Append(",");
                    AssetsReporterUtils.AddJsonObject(sb, "type", obj.GetType().Name);
                    if (obj.GetType() != typeof(GameObject))
                    {
                        Resources.UnloadAsset(obj);
                    }
                    // thumnail
                    {
                        if (obj.GetType() == typeof(Texture2D) && !AssetsReporterUtils.IsVisibleInWebBrowserImage(path))
                        {
                            sb.Append(",");
                            string preview = AssetsReporterUtils.GetWebVisibleTexturePreview(TextureImporter.GetAtPath(path) as TextureImporter, obj as Texture2D, this.createThumnailPreview);
                            AssetsReporterUtils.AddJsonObject(sb, "preview", preview);
                        }
                        else if (obj.GetType() == typeof(GameObject))
                        {
                            sb.Append(",");
                            var    assetImporter = AssetImporter.GetAtPath(path);
                            string preview       = AssetsReporterUtils.GetAssetPreview(assetImporter, obj, this.createThumnailPreview || ((assetImporter as ModelImporter) == null));
                            AssetsReporterUtils.AddJsonObject(sb, "preview", preview);
                        }
                    }

                    obj = null;
                }
                sb.Append("}");
            }
            sb.Append("],\n");
            this.RemoveDependsAssetBundle(paths);
            this.ReportDependsAssetBundle(sb);
            sb.Append("}\n");
        }
Esempio n. 23
0
        private void ReportTexture(StringBuilder sb, TextureImporter importer)
        {
            int w, h;
            var type    = importer.textureType;
            int maxSize = importer.maxTextureSize;

#if UNITY_5_5_OR_NEWER
            var defaultTextureSetting = importer.GetDefaultPlatformTextureSettings();
            var format = defaultTextureSetting.format;
            if (!importer.GetPlatformTextureSettings(this.platform, out maxSize, out format))
            {
                maxSize = importer.maxTextureSize;
                format  = defaultTextureSetting.format;
            }
#else
            var format = importer.textureFormat;
            if (!importer.GetPlatformTextureSettings(this.platform, out maxSize, out format))
            {
                maxSize = importer.maxTextureSize;
                format  = importer.textureFormat;
            }
#endif

            var tex = GetTextureSize(importer, out w, out h) as Texture2D;
            sb.Append("{");
            if (tex != null)
            {
                if (!AssetsReporterUtils.IsVisibleInWebBrowserImage(importer.assetPath))
                {
                    string preview = AssetsReporterUtils.GetWebVisibleTexturePreview(importer, tex, true);
                    AssetsReporterUtils.AddJsonObject(sb, "preview", preview).Append(",");
                }
            }

            AssetsReporterUtils.AddJsonObject(sb, "path", importer.assetPath.ToString()).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "textureType", type.ToString()).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "isReadable", importer.isReadable).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "wrapMode", importer.wrapMode.ToString()).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "mipmapEnabled", importer.mipmapEnabled).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "width", w).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "height", h).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "maxSize", maxSize).Append(",");
            AssetsReporterUtils.AddJsonObject(sb, "textureFormat", format.ToString()).Append(",");
            if (string.IsNullOrEmpty(importer.spritePackingTag))
            {
                AssetsReporterUtils.AddJsonObject(sb, "isPow2", IsPow2Size(w, h)).Append(",");
            }
            else
            {
                AssetsReporterUtils.AddJsonObject(sb, "isPow2", true).Append(",");
            }
            AssetsReporterUtils.AddJsonObject(sb, "spritePackingTag", importer.spritePackingTag);
            sb.Append("}");
            if (tex != null)
            {
                Resources.UnloadAsset(tex);
                tex = null;
            }

            AssetsReporterUtils.AddCountDictionary(this.spriteTagSet, importer.spritePackingTag);
            AssetsReporterUtils.AddCountDictionary(this.textureFormatSet, format);
            AssetsReporterUtils.AddCountDictionary(this.textureTypeSet, type);
        }
        private void SetParentDictionarySet(string path)
        {
            string parent = this.GetParentDirectory(path);

            AssetsReporterUtils.AddCountDictionary(this.parentDirDict, parent);
        }