示例#1
0
            public override void InitDetailCheckObject(Object obj)
            {
                MeshChecker   checker  = currentChecker as MeshChecker;
                Mesh          mesh     = obj as Mesh;
                ModelImporter importer = AssetImporter.GetAtPath(assetPath) as ModelImporter;

                //Mesh的object直接指向FBX根物体
                checkObject = AssetDatabase.LoadAssetAtPath <Object>(assetPath);
                checkMap[checker.previewItem] = AssetPreview.GetMiniThumbnail(checkObject);
                string readable            = buildInType;
                string compression         = buildInType;
                string tangent             = buildInType;
                string optimize            = buildInType;
                string normal              = buildInType;
                string blendshape          = buildInType;
                string animation           = buildInType;
                string genCollider         = buildInType;
                string keepQuads           = buildInType;
                string swapUVs             = buildInType;
                string generateLightMapUVs = buildInType;
                float  scale = 1.0f;

                if (importer != null)
                {
                    readable            = importer.isReadable.ToString();
                    optimize            = importer.optimizeMesh.ToString();
                    blendshape          = importer.importBlendShapes.ToString();
                    animation           = importer.animationType.ToString();
                    normal              = importer.importNormals.ToString();
                    tangent             = importer.importTangents.ToString();
                    compression         = importer.meshCompression.ToString();
                    genCollider         = importer.addCollider.ToString();
                    swapUVs             = importer.swapUVChannels.ToString();
                    generateLightMapUVs = importer.generateSecondaryUV.ToString();
                    scale = importer.globalScale;
                }
                checkMap.Add(checker.meshSubMeshCount, 0);
                checkMap.Add(checker.meshVertexCount, 0);
                checkMap.Add(checker.meshTrangleCount, 0);
                if (mesh == null && checker.isReloadCheckItem)
                {
                    List <string> oriSubMeshList = subMeshList.Select(x => x.name).ToList();
                    subMeshList.Clear();
                    foreach (var v in EditorUtility.CollectDependencies(new Object[] { obj }))
                    {
                        if (v is Mesh)
                        {
                            mesh = v as Mesh;
                            if (oriSubMeshList.Contains(mesh.name))
                            {
                                AddSubMesh(mesh, checker);
                            }
                        }
                    }
                }
                checkMap.Add(checker.meshFormat, GetMeshFormat(mesh));
                checkMap.Add(checker.meshReadable, readable);
                checkMap.Add(checker.meshImortBlendShaps, blendshape);
                checkMap.Add(checker.meshGenCollider, genCollider);
                checkMap.Add(checker.meshSwapUVs, swapUVs);
                checkMap.Add(checker.meshGenLightMapUVs, generateLightMapUVs);
                checkMap.Add(checker.meshKeepQuads, keepQuads);
                checkMap.Add(checker.meshOptimized, optimize);
                checkMap.Add(checker.meshAnimSetting, animation);
                checkMap.Add(checker.meshCompression, compression);
                checkMap.Add(checker.meshTanSetting, tangent);
                checkMap.Add(checker.meshNormalSetting, normal);
                checkMap.Add(checker.meshScaleFactor, scale);
            }
示例#2
0
    void CheckResources()
    {
        ActiveTextures.Clear();
        ActiveMaterials.Clear();
        ActiveMeshDetails.Clear();

        Renderer[] renderers = (Renderer[])FindObjectsOfType(typeof(Renderer));
        //Debug.Log("Total renderers "+renderers.Length);
        foreach (Renderer renderer in renderers)
        {
            //Debug.Log("Renderer is "+renderer.name);
            foreach (Material material in renderer.sharedMaterials)
            {
                MaterialDetails tMaterialDetails = FindMaterialDetails(material);
                if (tMaterialDetails == null)
                {
                    tMaterialDetails          = new MaterialDetails();
                    tMaterialDetails.material = material;
                    ActiveMaterials.Add(tMaterialDetails);
                }
                tMaterialDetails.FoundInRenderers.Add(renderer.gameObject);
            }
        }
        // counting NGUI components.
        UIWidget [] widegets = FindObjectsOfType(typeof(UIWidget)) as UIWidget[];
        foreach (UIWidget w in widegets)
        {
            MaterialDetails tMaterialDetails = FindMaterialDetails(w.material);
            if (tMaterialDetails == null)
            {
                tMaterialDetails          = new MaterialDetails();
                tMaterialDetails.material = w.material;
                ActiveMaterials.Add(tMaterialDetails);
            }
            tMaterialDetails.FoundInRenderers.Add(w.gameObject);
        }

        foreach (MaterialDetails tMaterialDetails in ActiveMaterials)
        {
            Material tMaterial = tMaterialDetails.material;
            foreach (Object obj in EditorUtility.CollectDependencies(new UnityEngine.Object[] { tMaterial }))
            {
                if (obj is Texture)
                {
                    Texture        tTexture        = obj as Texture;
                    TextureDetails tTextureDetails = FindTextureDetails(tTexture);
                    if (tTextureDetails == null)
                    {
                        tTextureDetails           = new TextureDetails();
                        tTextureDetails.texture   = tTexture;
                        tTextureDetails.isCubeMap = tTexture is Cubemap;

                        int memSize = CalculateTextureSizeBytes(tTexture);

                        tTextureDetails.memSizeKB = memSize / 1024;
                        TextureFormat tFormat      = TextureFormat.RGBA32;
                        int           tMipMapCount = 1;
                        if (tTexture is Texture2D)
                        {
                            tFormat      = (tTexture as Texture2D).format;
                            tMipMapCount = (tTexture as Texture2D).mipmapCount;
                        }
                        if (tTexture is Cubemap)
                        {
                            tFormat = (tTexture as Cubemap).format;
                        }

                        tTextureDetails.format      = tFormat;
                        tTextureDetails.mipMapCount = tMipMapCount;
                        ActiveTextures.Add(tTextureDetails);
                    }
                    tTextureDetails.FoundInMaterials.Add(tMaterial);
                    foreach (Object renderer in tMaterialDetails.FoundInRenderers)
                    {
                        if (!tTextureDetails.FoundInRenderers.Contains(renderer))
                        {
                            tTextureDetails.FoundInRenderers.Add(renderer);
                        }
                    }
                }
            }
        }


        MeshFilter[] meshFilters = (MeshFilter[])FindObjectsOfType(typeof(MeshFilter));

        foreach (MeshFilter tMeshFilter in meshFilters)
        {
            Mesh tMesh = tMeshFilter.sharedMesh;
            if (tMesh != null)
            {
                MeshDetails tMeshDetails = FindMeshDetails(tMesh);
                if (tMeshDetails == null)
                {
                    tMeshDetails      = new MeshDetails();
                    tMeshDetails.mesh = tMesh;
                    ActiveMeshDetails.Add(tMeshDetails);
                }
                tMeshDetails.FoundInMeshFilters.Add(tMeshFilter);
            }
        }

        SkinnedMeshRenderer[] skinnedMeshRenderers = (SkinnedMeshRenderer[])FindObjectsOfType(typeof(SkinnedMeshRenderer));

        foreach (SkinnedMeshRenderer tSkinnedMeshRenderer in skinnedMeshRenderers)
        {
            Mesh tMesh = tSkinnedMeshRenderer.sharedMesh;
            if (tMesh != null)
            {
                MeshDetails tMeshDetails = FindMeshDetails(tMesh);
                if (tMeshDetails == null)
                {
                    tMeshDetails      = new MeshDetails();
                    tMeshDetails.mesh = tMesh;
                    ActiveMeshDetails.Add(tMeshDetails);
                }
                tMeshDetails.FoundInSkinnedMeshRenderer.Add(tSkinnedMeshRenderer);
            }
        }


        TotalTextureMemory = 0;
        foreach (TextureDetails tTextureDetails in ActiveTextures)
        {
            TotalTextureMemory += tTextureDetails.memSizeKB;
        }

        TotalMeshVertices = 0;
        foreach (MeshDetails tMeshDetails in ActiveMeshDetails)
        {
            TotalMeshVertices += tMeshDetails.mesh.vertexCount;
        }

        // Sort by size, descending
        ActiveTextures.Sort(delegate(TextureDetails details1, TextureDetails details2) { return(details2.memSizeKB - details1.memSizeKB); });
        ActiveMeshDetails.Sort(delegate(MeshDetails details1, MeshDetails details2) { return(details2.mesh.vertexCount - details1.mesh.vertexCount); });
    }
示例#3
0
        private static void CollectUsedAssets(Scene scene, string sceneName, Dictionary <string, AssetInfo> assets, Dictionary <int, string> preexistingPrefabInstances, BuildInfoAssetDetailsCollector collector, out AssetProperty[] sceneDetails)
        {
            List <AssetProperty> details = new List <AssetProperty>();
            Func <string, UnityEngine.Object, AssetInfo> touchEntry = (assetPath, asset) =>
            {
                AssetInfo entry;
                if (!assets.TryGetValue(assetPath, out entry))
                {
                    entry = new AssetInfo()
                    {
                        path = assetPath,
                    };

                    assets.Add(assetPath, entry);
                }

                if (collector != null && entry.details == null)
                {
                    bool isMainAsset = true;
                    if (!AssetDatabase.IsMainAsset(asset) && !string.IsNullOrEmpty(AssetDatabase.GetAssetPath(asset)))
                    {
                        isMainAsset = false;
                    }

                    if (isMainAsset)
                    {
                        details.Clear();

                        Log.Debug("Collecting details for asset: {0}", assetPath);
                        collector.CollectForAsset(details, asset, assetPath);
                        entry.details = details.ToArray();
                    }
                    else
                    {
                        Log.Debug("Not a main asset: {0} {1}", asset.name, AssetDatabase.GetAssetPath(asset));
                    }
                }

                if (!string.IsNullOrEmpty(sceneName))
                {
                    int sceneIndex = entry.scenes.BinarySearch(sceneName);
                    if (sceneIndex < 0)
                    {
                        entry.scenes.Insert(~sceneIndex, sceneName);
                    }
                }
                return(entry);
            };

            var legacySpriteHandler = UnityVersionAgnostic.IsUsingLegacySpriteAtlases ? BuildInfoProcessorUtils.CreateLegacyAtlasHandler(touchEntry) : null;

            // include inactive ones too
            var sceneRoots = scene.GetRootGameObjects();

            sceneDetails = null;
            if (collector != null)
            {
                Log.Debug("Collecting scene details: {0}", sceneName);
                sceneDetails = collector.CollectForCurrentScene(sceneRoots);
            }

            Log.Debug("Processing scene objects for scene: {0}", sceneName);

            IEnumerable <UnityEngine.Object> objects = EditorUtility.CollectDependencies(sceneRoots).Where(x => x);

            foreach (var obj in objects)
            {
                string assetPath;
                var    dep = obj;

                if (!EditorUtility.IsPersistent(dep))
                {
                    if (dep is GameObject)
                    {
                        // hopefully this will work some day :(
                        // if (PrefabUtility.GetPrefabInstanceStatus(dep) == PrefabInstanceStatus.Connected)
                        // {
                        //
                        //     assetPath = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(dep);
                        // }
                        if (preexistingPrefabInstances != null)
                        {
                            // well, let's see if the workaround worked
                            preexistingPrefabInstances.TryGetValue(dep.GetInstanceID(), out assetPath);
                        }
                        else
                        {
                            assetPath = null;
                        }

                        if (string.IsNullOrEmpty(assetPath))
                        {
                            continue;
                        }

                        dep = AssetDatabase.LoadAssetAtPath <GameObject>(assetPath);

                        if (dep == null)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    assetPath = AssetDatabase.GetAssetPath(dep);
                }

                if (string.IsNullOrEmpty(assetPath))
                {
                    Log.Debug(dep, "empty path: name: {0}, scene: {1}", dep.name, sceneName);
                    continue;
                }

                touchEntry(assetPath, dep);

                if (legacySpriteHandler != null && dep is UnitySprite)
                {
                    legacySpriteHandler((UnitySprite)dep, assetPath);
                }
            }

            // add lightmaps
            Log.Debug("Processing lightmaps for scene: {0}", sceneName);
            foreach (var data in UnityEngine.LightmapSettings.lightmaps)
            {
                if (data.GetDirectional())
                {
                    touchEntry(AssetDatabase.GetAssetPath(data.GetDirectional()), data.GetDirectional());
                }
                if (data.GetLight())
                {
                    touchEntry(AssetDatabase.GetAssetPath(data.GetLight()), data.GetLight());
                }
            }

            // now check lightmap settings
            var lightmapSettings = BuildInfoProcessorUtils.GetLightmapSettings();

            for (var prop = new SerializedObject(lightmapSettings).GetIterator(); prop.Next(true);)
            {
                if (prop.propertyType == SerializedPropertyType.ObjectReference)
                {
                    var obj = prop.objectReferenceValue;
                    if (obj && EditorUtility.IsPersistent(obj))
                    {
                        string path = AssetDatabase.GetAssetPath(obj);
                        touchEntry(path, obj);
                    }
                }
            }
        }
示例#4
0
    public Dictionary <string, List <string> > FindResourceNotBeRefrences()
    {
        Dictionary <string, List <string> > dic = new Dictionary <string, List <string> >();
        List <SearchInfo> searchInfos           = new List <SearchInfo>();

        string[] searchGUIDArray = AssetDatabase.FindAssets(NOT_BE_REFRENCE_SOURCE_TYPE, new string[] { m_Src });
        //string[] srcPaths = new string[searchGUIDArray.Length];
        for (int i = 0; i < searchGUIDArray.Length; ++i)
        {
            searchInfos.Add(new SearchInfo(searchGUIDArray[i], AssetDatabase.GUIDToAssetPath(searchGUIDArray[i])));
        }
        string[] allGuids = AssetDatabase.FindAssets(ResourceRefrenceWindow.SEARCH_TYPE, new string[] { m_SearchDir });

        ShowProgress(0, allGuids.Length, 0);

        ResourceDependencyInfo[] allResources = new ResourceDependencyInfo[allGuids.Length];
        UnityEngine.Object[]     roots        = new UnityEngine.Object[1];
        for (int i = 0; i < allGuids.Length; ++i)
        {
            ResourceDependencyInfo info = new ResourceDependencyInfo();
            string guid = allGuids[i];
            string path = AssetDatabase.GUIDToAssetPath(guid);
            roots[0] = AssetDatabase.LoadAssetAtPath(path, typeof(UnityEngine.Object));
            UnityEngine.Object[] dependency      = EditorUtility.CollectDependencies(roots);
            string[]             dependencyPaths = new string[dependency.Length];
            for (int j = 0; j < dependency.Length; ++j)
            {
                dependencyPaths[j] = AssetDatabase.GetAssetPath(dependency[j]);
            }
            info.path            = path;
            info.dependencyPaths = dependencyPaths;
            allResources[i]      = info;
        }

        int threadCounts = Mathf.Min(Environment.ProcessorCount, allGuids.Length);

        FindNoRefrenceSearchJob[] searchJobsArray = new FindNoRefrenceSearchJob[threadCounts];
        ManualResetEvent[]        events          = new ManualResetEvent[threadCounts];
        for (int i = 0; i < threadCounts; ++i)
        {
            searchJobsArray[i] = new FindNoRefrenceSearchJob();
            events[i]          = searchJobsArray[i].doneEvent;
        }
        int timeout    = 600000; // 10 分钟超时
        int index      = 0;
        int step       = 10;
        int startIndex = 0;

        //Less then step * threadCounts
        for (; index < threadCounts; index++)
        {
            if (index * step >= allGuids.Length)
            {
                break;
            }

            FindNoRefrenceSearchJob job = searchJobsArray[index];
            job.SetData(startIndex, step, allResources, searchInfos);
            ThreadPool.QueueUserWorkItem(job.ThreadPoolCallback);

            ShowProgress((float)index * step / (float)(allGuids.Length), allGuids.Length, index * step);

            startIndex += step;
        }

        for (; index < threadCounts; ++index)
        {
            searchJobsArray[index].doneEvent.Set();
        }

        for (int i = index * step; i < allGuids.Length; i += step)
        {
            index = WaitForDoFile(events, timeout);
            FindNoRefrenceSearchJob job = searchJobsArray[index];
            job.SetData(startIndex, step, allResources, searchInfos);
            ThreadPool.QueueUserWorkItem(job.ThreadPoolCallback);

            ShowProgress((float)i / (float)(allGuids.Length), allGuids.Length, i);

            startIndex += step;
        }

        WaitHandle.WaitAll(events, timeout);

        List <string> prefabList  = new List <string>();
        List <string> sceneList   = new List <string>();
        List <string> matList     = new List <string>();
        List <string> fbxList     = new List <string>();
        List <string> textureList = new List <string>();
        List <string> otherList   = new List <string>();

        foreach (var iter in searchInfos)
        {
            if (!iter.searched)
            {
                string guid = iter.guid;
                string path = AssetDatabase.GUIDToAssetPath(guid);
                if (path.Contains("Lightmap") || path.Contains("ReflectionProbe"))
                {
                    continue;
                }
                if (path.EndsWith(".prefab"))
                {
                    prefabList.Add(path);
                    continue;
                }
                else if (path.EndsWith(".unity"))
                {
                    sceneList.Add(path);
                    continue;
                }
                else if (path.EndsWith(".mat"))
                {
                    matList.Add(path);
                    continue;
                }
                else if (path.EndsWith(".FBX"))
                {
                    fbxList.Add(path);
                    continue;
                }
                else if (path.EndsWith("png") || path.EndsWith("tga"))
                {
                    textureList.Add(path);
                    continue;
                }
                else
                {
                    otherList.Add(path);
                }
            }
        }

        dic.Add("Prefab", prefabList);
        dic.Add("Material", matList);
        dic.Add("Scene", sceneList);
        dic.Add("FBX", fbxList);
        dic.Add("Texture", textureList);
        dic.Add("Other", otherList);

        EditorUtility.ClearProgressBar();

        return(dic);
    }
    void CheckResources()
    {
        ActiveTextures.Clear();
        ActiveMaterials.Clear();
        ActiveMeshDetails.Clear();
        MissingObjects.Clear();
        thingsMissing = false;

        Renderer[] renderers = FindObjects <Renderer>();

        MaterialDetails skyMat = new MaterialDetails();

        skyMat.material = RenderSettings.skybox;
        skyMat.isSky    = true;
        ActiveMaterials.Add(skyMat);

        //Debug.Log("Total renderers "+renderers.Length);
        foreach (Renderer renderer in renderers)
        {
            //Debug.Log("Renderer is "+renderer.name);
            foreach (Material material in renderer.sharedMaterials)
            {
                MaterialDetails tMaterialDetails = FindMaterialDetails(material);
                if (tMaterialDetails == null)
                {
                    tMaterialDetails          = new MaterialDetails();
                    tMaterialDetails.material = material;
                    ActiveMaterials.Add(tMaterialDetails);
                }
                tMaterialDetails.FoundInRenderers.Add(renderer);
            }

            if (renderer is SpriteRenderer)
            {
                SpriteRenderer tSpriteRenderer = (SpriteRenderer)renderer;

                if (tSpriteRenderer.sprite != null)
                {
                    var tSpriteTextureDetail = GetTextureDetail(tSpriteRenderer.sprite.texture, renderer);
                    if (!ActiveTextures.Contains(tSpriteTextureDetail))
                    {
                        ActiveTextures.Add(tSpriteTextureDetail);
                    }
                }
                else if (tSpriteRenderer.sprite == null)
                {
                    MissingGraphic tMissing = new MissingGraphic();
                    tMissing.Object = tSpriteRenderer.transform;
                    tMissing.type   = "sprite";
                    tMissing.name   = tSpriteRenderer.transform.name;
                    MissingObjects.Add(tMissing);
                    thingsMissing = true;
                }
            }
        }

        if (IncludeLightmapTextures)
        {
            LightmapData[] lightmapTextures = LightmapSettings.lightmaps;

            // Unity lightmaps
            foreach (LightmapData lightmapData in lightmapTextures)
            {
                if (lightmapData.lightmapColor != null)
                {
                    var textureDetail = GetTextureDetail(lightmapData.lightmapColor);

                    if (!ActiveTextures.Contains(textureDetail))
                    {
                        ActiveTextures.Add(textureDetail);
                    }
                }

                if (lightmapData.lightmapDir != null)
                {
                    var textureDetail = GetTextureDetail(lightmapData.lightmapColor);

                    if (!ActiveTextures.Contains(textureDetail))
                    {
                        ActiveTextures.Add(textureDetail);
                    }
                }

                if (lightmapData.shadowMask != null)
                {
                    var textureDetail = GetTextureDetail(lightmapData.shadowMask);

                    if (!ActiveTextures.Contains(textureDetail))
                    {
                        ActiveTextures.Add(textureDetail);
                    }
                }
            }
        }

        if (IncludeGuiElements)
        {
            Graphic[] graphics = FindObjects <Graphic>();

            foreach (Graphic graphic in graphics)
            {
                if (graphic.mainTexture)
                {
                    var tSpriteTextureDetail = GetTextureDetail(graphic.mainTexture, graphic);
                    if (!ActiveTextures.Contains(tSpriteTextureDetail))
                    {
                        ActiveTextures.Add(tSpriteTextureDetail);
                    }
                }

                if (graphic.materialForRendering)
                {
                    MaterialDetails tMaterialDetails = FindMaterialDetails(graphic.materialForRendering);
                    if (tMaterialDetails == null)
                    {
                        tMaterialDetails          = new MaterialDetails();
                        tMaterialDetails.material = graphic.materialForRendering;
                        tMaterialDetails.isgui    = true;
                        ActiveMaterials.Add(tMaterialDetails);
                    }
                    tMaterialDetails.FoundInGraphics.Add(graphic);
                }
            }

            Button[] buttons = FindObjects <Button>();
            foreach (Button button in buttons)
            {
                CheckButtonSpriteState(button, button.spriteState.disabledSprite);
                CheckButtonSpriteState(button, button.spriteState.highlightedSprite);
                CheckButtonSpriteState(button, button.spriteState.pressedSprite);
            }
        }

        foreach (MaterialDetails tMaterialDetails in ActiveMaterials)
        {
            Material tMaterial = tMaterialDetails.material;
            if (tMaterial != null)
            {
                var dependencies = EditorUtility.CollectDependencies(new UnityEngine.Object[] { tMaterial });
                foreach (Object obj in dependencies)
                {
                    if (obj is Texture)
                    {
                        Texture tTexture       = obj as Texture;
                        var     tTextureDetail = GetTextureDetail(tTexture, tMaterial, tMaterialDetails);
                        tTextureDetail.isSky    = tMaterialDetails.isSky;
                        tTextureDetail.instance = tMaterialDetails.instance;
                        tTextureDetail.isgui    = tMaterialDetails.isgui;
                        ActiveTextures.Add(tTextureDetail);
                    }
                }

                //if the texture was downloaded, it won't be included in the editor dependencies
                if (tMaterial.HasProperty("_MainTex"))
                {
                    if (tMaterial.mainTexture != null && !dependencies.Contains(tMaterial.mainTexture))
                    {
                        var tTextureDetail = GetTextureDetail(tMaterial.mainTexture, tMaterial, tMaterialDetails);
                        ActiveTextures.Add(tTextureDetail);
                    }
                }
            }
        }


        MeshFilter[] meshFilters = FindObjects <MeshFilter>();

        foreach (MeshFilter tMeshFilter in meshFilters)
        {
            Mesh tMesh = tMeshFilter.sharedMesh;
            if (tMesh != null)
            {
                MeshDetails tMeshDetails = FindMeshDetails(tMesh);
                if (tMeshDetails == null)
                {
                    tMeshDetails      = new MeshDetails();
                    tMeshDetails.mesh = tMesh;
                    ActiveMeshDetails.Add(tMeshDetails);
                }
                tMeshDetails.FoundInMeshFilters.Add(tMeshFilter);

                if (GameObjectUtility.AreStaticEditorFlagsSet(tMeshFilter.gameObject, StaticEditorFlags.BatchingStatic))
                {
                    tMeshDetails.StaticBatchingEnabled.Add(tMeshFilter.gameObject);
                }
            }
            else if (tMesh == null && tMeshFilter.transform.GetComponent("TextContainer") == null)
            {
                MissingGraphic tMissing = new MissingGraphic();
                tMissing.Object = tMeshFilter.transform;
                tMissing.type   = "mesh";
                tMissing.name   = tMeshFilter.transform.name;
                MissingObjects.Add(tMissing);
                thingsMissing = true;
            }

            var meshRenderrer = tMeshFilter.transform.GetComponent <MeshRenderer>();

            if (meshRenderrer == null || meshRenderrer.sharedMaterial == null)
            {
                MissingGraphic tMissing = new MissingGraphic();
                tMissing.Object = tMeshFilter.transform;
                tMissing.type   = "material";
                tMissing.name   = tMeshFilter.transform.name;
                MissingObjects.Add(tMissing);
                thingsMissing = true;
            }
        }

        SkinnedMeshRenderer[] skinnedMeshRenderers = FindObjects <SkinnedMeshRenderer>();

        foreach (SkinnedMeshRenderer tSkinnedMeshRenderer in skinnedMeshRenderers)
        {
            Mesh tMesh = tSkinnedMeshRenderer.sharedMesh;
            if (tMesh != null)
            {
                MeshDetails tMeshDetails = FindMeshDetails(tMesh);
                if (tMeshDetails == null)
                {
                    tMeshDetails      = new MeshDetails();
                    tMeshDetails.mesh = tMesh;
                    ActiveMeshDetails.Add(tMeshDetails);
                }
                tMeshDetails.FoundInSkinnedMeshRenderer.Add(tSkinnedMeshRenderer);
            }
            else if (tMesh == null)
            {
                MissingGraphic tMissing = new MissingGraphic();
                tMissing.Object = tSkinnedMeshRenderer.transform;
                tMissing.type   = "mesh";
                tMissing.name   = tSkinnedMeshRenderer.transform.name;
                MissingObjects.Add(tMissing);
                thingsMissing = true;
            }
            if (tSkinnedMeshRenderer.sharedMaterial == null)
            {
                MissingGraphic tMissing = new MissingGraphic();
                tMissing.Object = tSkinnedMeshRenderer.transform;
                tMissing.type   = "material";
                tMissing.name   = tSkinnedMeshRenderer.transform.name;
                MissingObjects.Add(tMissing);
                thingsMissing = true;
            }
        }

        if (IncludeSpriteAnimations)
        {
            Animator[] animators = FindObjects <Animator>();
            foreach (Animator anim in animators)
            {
                UnityEditor.Animations.AnimatorController ac = anim.runtimeAnimatorController as UnityEditor.Animations.AnimatorController;

                //Skip animators without layers, this can happen if they don't have an animator controller.
                if (!ac || ac.layers == null || ac.layers.Length == 0)
                {
                    continue;
                }

                for (int x = 0; x < anim.layerCount; x++)
                {
                    UnityEditor.Animations.AnimatorStateMachine sm = ac.layers[x].stateMachine;
                    int cnt = sm.states.Length;

                    for (int i = 0; i < cnt; i++)
                    {
                        UnityEditor.Animations.AnimatorState state = sm.states[i].state;
                        Motion m = state.motion;
                        if (m != null)
                        {
                            AnimationClip clip = m as AnimationClip;

                            if (clip != null)
                            {
                                EditorCurveBinding[] ecbs = AnimationUtility.GetObjectReferenceCurveBindings(clip);

                                foreach (EditorCurveBinding ecb in ecbs)
                                {
                                    if (ecb.propertyName == "m_Sprite")
                                    {
                                        foreach (ObjectReferenceKeyframe keyframe in AnimationUtility.GetObjectReferenceCurve(clip, ecb))
                                        {
                                            Sprite tSprite = keyframe.value as Sprite;

                                            if (tSprite != null)
                                            {
                                                var tTextureDetail = GetTextureDetail(tSprite.texture, anim);
                                                if (!ActiveTextures.Contains(tTextureDetail))
                                                {
                                                    ActiveTextures.Add(tTextureDetail);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        if (IncludeScriptReferences)
        {
            MonoBehaviour[] scripts = FindObjects <MonoBehaviour>();
            foreach (MonoBehaviour script in scripts)
            {
                BindingFlags flags  = BindingFlags.Public | BindingFlags.Instance; // only public non-static fields are bound to by Unity.
                FieldInfo[]  fields = script.GetType().GetFields(flags);

                foreach (FieldInfo field in fields)
                {
                    System.Type fieldType = field.FieldType;
                    if (fieldType == typeof(Sprite))
                    {
                        Sprite tSprite = field.GetValue(script) as Sprite;
                        if (tSprite != null)
                        {
                            var tSpriteTextureDetail = GetTextureDetail(tSprite.texture, script);
                            if (!ActiveTextures.Contains(tSpriteTextureDetail))
                            {
                                ActiveTextures.Add(tSpriteTextureDetail);
                            }
                        }
                    }
                    if (fieldType == typeof(Mesh))
                    {
                        Mesh tMesh = field.GetValue(script) as Mesh;
                        if (tMesh != null)
                        {
                            MeshDetails tMeshDetails = FindMeshDetails(tMesh);
                            if (tMeshDetails == null)
                            {
                                tMeshDetails          = new MeshDetails();
                                tMeshDetails.mesh     = tMesh;
                                tMeshDetails.instance = true;
                                ActiveMeshDetails.Add(tMeshDetails);
                            }
                        }
                    }
                    if (fieldType == typeof(Material))
                    {
                        Material tMaterial = field.GetValue(script) as Material;
                        if (tMaterial != null)
                        {
                            MaterialDetails tMatDetails = FindMaterialDetails(tMaterial);
                            if (tMatDetails == null)
                            {
                                tMatDetails          = new MaterialDetails();
                                tMatDetails.instance = true;
                                tMatDetails.material = tMaterial;
                                if (!ActiveMaterials.Contains(tMatDetails))
                                {
                                    ActiveMaterials.Add(tMatDetails);
                                }
                            }
                            if (tMaterial.mainTexture)
                            {
                                var tSpriteTextureDetail = GetTextureDetail(tMaterial.mainTexture);
                                if (!ActiveTextures.Contains(tSpriteTextureDetail))
                                {
                                    ActiveTextures.Add(tSpriteTextureDetail);
                                }
                            }
                            var dependencies = EditorUtility.CollectDependencies(new UnityEngine.Object[] { tMaterial });
                            foreach (Object obj in dependencies)
                            {
                                if (obj is Texture)
                                {
                                    Texture tTexture       = obj as Texture;
                                    var     tTextureDetail = GetTextureDetail(tTexture, tMaterial, tMatDetails);
                                    if (!ActiveTextures.Contains(tTextureDetail))
                                    {
                                        ActiveTextures.Add(tTextureDetail);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        TotalTextureMemory = 0;
        foreach (TextureDetails tTextureDetails in ActiveTextures)
        {
            TotalTextureMemory += tTextureDetails.memSizeKB;
        }

        TotalMeshVertices = 0;
        foreach (MeshDetails tMeshDetails in ActiveMeshDetails)
        {
            TotalMeshVertices += tMeshDetails.mesh.vertexCount;
        }

        // Sort by size, descending
        ActiveTextures.Sort(delegate(TextureDetails details1, TextureDetails details2) { return(details2.memSizeKB - details1.memSizeKB); });
        ActiveTextures = ActiveTextures.Distinct().ToList();
        ActiveMeshDetails.Sort(delegate(MeshDetails details1, MeshDetails details2) { return(details2.mesh.vertexCount - details1.mesh.vertexCount); });

        collectedInPlayingMode = Application.isPlaying;

        // Sort by render queue
        ActiveMaterials.Sort(MaterialSorter);
    }
示例#6
0
    public static void SetResourceBundleName(Dictionary <string, string> resources)
    {
        string[] bundleNames = AssetDatabase.GetAllAssetBundleNames();
        foreach (var bundleName in bundleNames)
        {
            //if (bundleName == ("ui/countdown.common"))
            {
                string[] bundleAssets = AssetDatabase.GetAssetPathsFromAssetBundle(bundleName);
                foreach (var bundleAsset in bundleAssets)
                {
                    var prefabImporter = AssetImporter.GetAtPath(bundleAsset);
                    prefabImporter.assetBundleVariant = "";
                    prefabImporter.assetBundleName    = "";
                }
            }
        }

        Dictionary <string, string> dependBundles = new Dictionary <string, string>();

        foreach (var res in resources)
        {
            string resAssetPath   = res.Key;
            var    prefabImporter = AssetImporter.GetAtPath(resAssetPath);
            if (prefabImporter != null)
            {
                prefabImporter.assetBundleName    = res.Value;
                prefabImporter.assetBundleVariant = "common";
            }
            Debug.Log("SetResourceBundleName:" + res.Value + "," + resAssetPath);

            Object   assetData  = AssetDatabase.LoadAssetAtPath <Object>(resAssetPath);
            Object[] dependObjs = EditorUtility.CollectDependencies(new Object[1] {
                assetData
            });
            foreach (var dependObj in dependObjs)
            {
                if (dependObj == null)
                {
                    continue;
                }

                if (dependObj is UnityEngine.Mesh ||
                    dependObj is Texture2D ||
                    dependObj is Material ||
                    dependObj is Animation ||
                    dependObj is AudioClip ||
                    dependObj is GameObject ||
                    dependObj is Shader
                    )
                {
                    string dependObjPath = AssetDatabase.GetAssetPath(dependObj);
                    if (dependObjPath.Contains("unity default resources"))
                    {
                        continue;
                    }

                    if (dependObjPath.StartsWith("Resources/"))
                    {
                        continue;
                    }

                    string dependObjObsorbPath = dependObjPath;
                    if (resources.ContainsKey(dependObjObsorbPath))
                    {
                        continue;
                    }

                    if (dependObj == assetData)
                    {
                        continue;
                    }

                    if (!dependBundles.ContainsKey(dependObjPath))
                    {
                        dependBundles.Add(dependObjPath, "");
                    }
                    dependBundles[dependObjPath] += res.Value;

                    if (dependObj is Shader)
                    {
                        dependBundles[dependObjPath] = "Shader";
                    }
                }
            }
        }

        foreach (var dependBundle in dependBundles)
        {
            string dependBundleName = "Depend/Depend_" + EncryptWithMD5(dependBundle.Value);
            if (dependBundle.Value.Equals("Shader"))
            {
                dependBundleName = "Shader";
            }
            //Debug.Log("SetResourceBundleName:" + dependBundleName + "," + dependBundle.Key);
            var prefabImporter = AssetImporter.GetAtPath(dependBundle.Key);
            if (prefabImporter != null)
            {
                prefabImporter.assetBundleName    = dependBundleName;
                prefabImporter.assetBundleVariant = "common";
            }
        }
    }
示例#7
0
    public void GeneratePrefabReferences()
    {
        bool undoRecorded = false;

        if (this.prefabs.RemoveAll(item => item == null) > 0)
        {
            Undo.RecordObject(this, "Update Easy Save 3 Reference List");
            undoRecorded = true;
        }

        var es3Prefabs = Resources.FindObjectsOfTypeAll <ES3Prefab>();

        if (es3Prefabs.Length == 0)
        {
            return;
        }

        foreach (var es3Prefab in es3Prefabs)
        {
            if (PrefabUtility.GetPrefabType(es3Prefab.gameObject) != PrefabType.Prefab)
            {
                continue;
            }

            if (GetPrefab(es3Prefab) != -1)
            {
                AddPrefab(es3Prefab);
                if (!undoRecorded)
                {
                    Undo.RecordObject(this, "Update Easy Save 3 Reference List");
                    undoRecorded = true;
                }
            }

            bool prefabUndoRecorded = false;

            if (es3Prefab.localRefs.RemoveNullKeys() > 0)
            {
                Undo.RecordObject(es3Prefab, "Update Easy Save 3 Prefab");
                prefabUndoRecorded = true;
            }

            // Get GameObject and it's children and add them to the reference list.
            foreach (var obj in EditorUtility.CollectDependencies(new UnityEngine.Object[] { es3Prefab }))
            {
                if (!CanBeSaved(obj))
                {
                    continue;
                }

                if (es3Prefab.Get(obj) != -1)
                {
                    es3Prefab.Add(obj);
                    if (!prefabUndoRecorded)
                    {
                        Undo.RecordObject(es3Prefab, "Update Easy Save 3 Prefab");
                        prefabUndoRecorded = true;
                    }
                }
            }
        }
    }
    void CheckResources()
    {
        ActiveTextures.Clear();
        ActiveMaterials.Clear();
        ActiveMeshDetails.Clear();

        Renderer[] renderers = (Renderer[])FindObjectsOfType(typeof(Renderer));
        //Debug.Log("Total renderers "+renderers.Length);
        foreach (Renderer renderer in renderers)
        {
            //Debug.Log("Renderer is "+renderer.name);
            foreach (Material material in renderer.sharedMaterials)
            {
                MaterialDetails tMaterialDetails = FindMaterialDetails(material);
                if (tMaterialDetails == null)
                {
                    tMaterialDetails          = new MaterialDetails();
                    tMaterialDetails.material = material;
                    ActiveMaterials.Add(tMaterialDetails);
                }
                tMaterialDetails.FoundInRenderers.Add(renderer);
            }
        }

        UISprite[] sprites = (UISprite[])FindObjectsOfType(typeof(UISprite));

        //Debug.Log("Renderer is "+renderer.name);
        foreach (UISprite sprite in sprites)
        {
            if (sprite.atlas != null && sprite.atlas.spriteMaterial != null)
            {
                Material        material         = sprite.atlas.spriteMaterial;
                MaterialDetails tMaterialDetails = FindMaterialDetails(material);
                if (tMaterialDetails == null)
                {
                    tMaterialDetails          = new MaterialDetails();
                    tMaterialDetails.material = material;
                    ActiveMaterials.Add(tMaterialDetails);
                }
            }
        }


        foreach (MaterialDetails tMaterialDetails in ActiveMaterials)
        {
            Material tMaterial    = tMaterialDetails.material;
            var      dependencies = EditorUtility.CollectDependencies(new UnityEngine.Object[] { tMaterial });
            foreach (Object obj in dependencies)
            {
                if (obj is Texture)
                {
                    Texture tTexture       = obj as Texture;
                    var     tTextureDetail = GetTextureDetail(tTexture, tMaterial, tMaterialDetails);
                    ActiveTextures.Add(tTextureDetail);
                }
            }

            //if the texture was downloaded, it won't be included in the editor dependencies
            if (tMaterial.mainTexture != null && !dependencies.Contains(tMaterial.mainTexture))
            {
                var tTextureDetail = GetTextureDetail(tMaterial.mainTexture, tMaterial, tMaterialDetails);
                ActiveTextures.Add(tTextureDetail);
            }
        }


        MeshFilter[] meshFilters = (MeshFilter[])FindObjectsOfType(typeof(MeshFilter));

        foreach (MeshFilter tMeshFilter in meshFilters)
        {
            Mesh tMesh = tMeshFilter.sharedMesh;
            if (tMesh != null)
            {
                MeshDetails tMeshDetails = FindMeshDetails(tMesh);
                if (tMeshDetails == null)
                {
                    tMeshDetails      = new MeshDetails();
                    tMeshDetails.mesh = tMesh;
                    ActiveMeshDetails.Add(tMeshDetails);
                }
                tMeshDetails.FoundInMeshFilters.Add(tMeshFilter);
            }
        }

        SkinnedMeshRenderer[] skinnedMeshRenderers = (SkinnedMeshRenderer[])FindObjectsOfType(typeof(SkinnedMeshRenderer));

        foreach (SkinnedMeshRenderer tSkinnedMeshRenderer in skinnedMeshRenderers)
        {
            Mesh tMesh = tSkinnedMeshRenderer.sharedMesh;
            if (tMesh != null)
            {
                MeshDetails tMeshDetails = FindMeshDetails(tMesh);
                if (tMeshDetails == null)
                {
                    tMeshDetails      = new MeshDetails();
                    tMeshDetails.mesh = tMesh;
                    ActiveMeshDetails.Add(tMeshDetails);
                }
                tMeshDetails.FoundInSkinnedMeshRenderer.Add(tSkinnedMeshRenderer);
            }
        }


        TotalTextureMemory = 0;
        foreach (TextureDetails tTextureDetails in ActiveTextures)
        {
            TotalTextureMemory += tTextureDetails.memSizeKB;
        }

        TotalMeshVertices = 0;
        foreach (MeshDetails tMeshDetails in ActiveMeshDetails)
        {
            TotalMeshVertices += tMeshDetails.mesh.vertexCount;
        }

        // Sort by size, descending
        ActiveTextures.Sort(delegate(TextureDetails details1, TextureDetails details2) {
            return(details2.memSizeKB - details1.memSizeKB);
        });
        ActiveMeshDetails.Sort(delegate(MeshDetails details1, MeshDetails details2) {
            return(details2.mesh.vertexCount - details1.mesh.vertexCount);
        });
    }
示例#9
0
        public override IEnumerable <ValidationProfileResult> Validate(ValidationRunner runner)
        {
            if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                yield break;
            }

            var selection    = Selection.objects;
            var scenesToTest = this.GetAllScenes().ToList();
            var setup        = EditorSceneManager.GetSceneManagerSetup();

            var partialProgress         = 0f;
            var partialProgressStepSize = 1f / (scenesToTest.Count + (this.IncludeAssetDependencies ? 1 : 0));

            try
            {
                for (int i = 0; i < scenesToTest.Count; i++)
                {
                    var scene = scenesToTest[i];

                    EditorSceneManager.OpenScene(scene, OpenSceneMode.Single);

                    var gameObjectsToScan = Resources.FindObjectsOfTypeAll <Transform>()
                                            .Where(x => (x.gameObject.scene.IsValid() && (x.gameObject.hideFlags & HideFlags.HideInHierarchy) == 0))
                                            //.SelectMany(x => x.GetComponents(typeof(Component)).Select(c => new { go = x.gameObject, component = c }))
                                            .ToList();

                    var step = 1f / gameObjectsToScan.Count;
                    for (int j = 0; j < gameObjectsToScan.Count; j++)
                    {
                        var go       = gameObjectsToScan[j].gameObject;
                        var progress = j * step * partialProgressStepSize + partialProgress;

                        {
                            var results = runner.ValidateUnityObjectRecursively(go);

                            var recoveryData = this.GetRecoveryData(go, null, scene);

                            var entry = new ValidationProfileResult()
                            {
                                Name               = go.name,
                                Profile            = this,
                                Source             = go,
                                Results            = results,
                                Progress           = progress,
                                SourceRecoveryData = recoveryData,
                                Path               = recoveryData.HierarchyPath,
                            };

                            yield return(entry);
                        }

                        var components = go.GetComponents <Component>();

                        for (int k = 0; k < components.Length; k++)
                        {
                            var component    = components[k];
                            var recoveryData = this.GetRecoveryData(go, component, scene);

                            if (component == null)
                            {
                                var entry = new ValidationProfileResult()
                                {
                                    Name               = go.name + " (Broken Component)",
                                    Source             = go,
                                    SourceRecoveryData = recoveryData,
                                    Profile            = this,
                                    Progress           = progress,
                                    Results            = new List <ValidationResult>()
                                    {
                                        new ValidationResult()
                                        {
                                            Message = object.ReferenceEquals(component, null) ?
                                                      "Broken Component: a component at index '" + k + "' is null on the GameObject '" + go.name + "'! A script reference is likely broken." :
                                                      "Broken Component: a component of type '" + component.GetType().GetNiceName() + "' at index '" + k + "' is null on the GameObject '" + go.name + "'! A script reference is likely broken.",
                                            ResultType = ValidationResultType.Error,
                                        }
                                    },
                                    Path = recoveryData.HierarchyPath,
                                };

                                yield return(entry);
                            }
                            else
                            {
                                var result = runner.ValidateUnityObjectRecursively(component);
                                var entry  = new ValidationProfileResult()
                                {
                                    Name               = go.name + " - " + component.GetType().GetNiceName().SplitPascalCase(),
                                    Profile            = this,
                                    Source             = component,
                                    Results            = result,
                                    Progress           = progress,
                                    SourceRecoveryData = this.GetRecoveryData(go, component, scene),
                                    Path               = recoveryData.HierarchyPath,
                                };

                                yield return(entry);
                            }
                        }
                    }
                    partialProgress += partialProgressStepSize;
                }
            }
            finally
            {
                // Load a new empty scene that will be unloaded immediately, just to be sure we completely clear all changes made by the scan
                EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);

                if (setup.Length != 0)
                {
                    EditorSceneManager.RestoreSceneManagerSetup(setup);
                }
            }

            if (this.IncludeAssetDependencies)
            {
                var scenes = new HashSet <UnityEngine.Object>(scenesToTest
                                                              .Select(x => AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(x))).ToArray();

                var dep               = EditorUtility.CollectDependencies(scenes);
                var components        = dep.OfType <Component>().ToList();
                var scriptableObjects = dep.OfType <ScriptableObject>().ToList();
                var allObjects        = components.Cast <UnityEngine.Object>().Concat(scriptableObjects.Cast <UnityEngine.Object>())
                                        .ToArray();



                var step = 1f / allObjects.Length;
                for (int i = 0; i < allObjects.Length; i++)
                {
                    var    obj      = allObjects[i];
                    var    progress = i * step * partialProgressStepSize + partialProgress;
                    var    result   = runner.ValidateUnityObjectRecursively(obj);
                    string path     = AssetDatabase.Contains(obj) ? AssetDatabase.GetAssetPath(obj) : "";

                    var entry = new ValidationProfileResult()
                    {
                        Name     = obj.name,
                        Profile  = this,
                        Source   = obj,
                        Results  = result,
                        Progress = progress,
                        Path     = path,
                    };

                    yield return(entry);
                }
            }

            Selection.objects = selection;
        }
        /// <summary>Finds references to passed objects and puts them in references</summary>
        private void FindObjectReferences(Object aToFind)
        {
            EditorUtility.DisplayProgressBar("Searching", "Generating file paths", 0.0f);

            // Get all prefabs in the project
            if (paths == null)
            {
                paths = new List <string>();
                GetFilePaths("Assets", ".prefab", ref paths);
            }

            int pathsCount = paths.Count;

            float progress        = 0;
            int   updateIteration = Mathf.Max(1, pathsCount / 100); // So we only update progress bar 100 times, not for every item

            Object[] searchArray = new Object[1];
            references.Clear();

            // Loop through all files, and add any that have the selected object in it's list of dependencies
            for (int i = 0; i < pathsCount; ++i)
            {
                searchArray[0] = AssetDatabase.LoadMainAssetAtPath(paths[i]);
                if (searchArray.Length > 0 && searchArray[0] != aToFind)
                {
                    Object[] dependencies = EditorUtility.CollectDependencies(searchArray);
                    if (ArrayUtility.Contains(dependencies, aToFind))
                    {
                        references.Add(searchArray[0] as GameObject);
                    }
                }

                if (i % updateIteration == 0)
                {
                    progress += 0.01f;
                    EditorUtility.DisplayProgressBar("Searching", "Searching dependencies", progress);
                }
            }

            EditorUtility.DisplayProgressBar("Searching", "Removing redundant references", 1);

            // Go through the references and remove any that are not direct dependencies.
            for (int i = references.Count - 1; i >= 0; i--)
            {
                searchArray[0] = references[i];
                Object[] dependencies = EditorUtility.CollectDependencies(searchArray);

                bool shouldRemove = false;

                for (int j = 0; j < dependencies.Length; j++)
                {
                    shouldRemove = (references.Find(item => item == dependencies[j] && item != searchArray[0]) != null);

                    if (shouldRemove)
                    {
                        break;
                    }
                }

                if (shouldRemove)
                {
                    references.RemoveAt(i);
                }
            }

            EditorUtility.ClearProgressBar();
        }
    private List <AnimationClip> GetClips()
    {
        var clips = EditorUtility.CollectDependencies(new Object[] { prefab }).ToList();

        foreach (var obj in clips.ToArray())
        {
            clips.AddRange(AssetDatabase.LoadAllAssetRepresentationsAtPath(AssetDatabase.GetAssetPath(obj)));
        }
        clips.AddRange(customClips.Select(q => (Object)q));
        clips.RemoveAll(q => q is AnimationClip == false || q == null);
        foreach (AnimationClip clip in clips)
        {
            if (bakeAnims.ContainsKey(clip.name) == false)
            {
                bakeAnims.Add(clip.name, true);
            }
        }
        clips.RemoveAll(q => bakeAnims.ContainsKey(q.name) == false);
        clips.RemoveAll(q => bakeAnims[q.name] == false);

        var distinctClips = clips.Select(q => (AnimationClip)q).Distinct().ToList();

        requiresAnimator = false;
        var humanoidCheck = new List <AnimationClip>(distinctClips);

        if (animController)
        {
            humanoidCheck.AddRange(animController.animationClips);
            distinctClips.AddRange(animController.animationClips);
            distinctClips = distinctClips.Distinct().ToList();
        }
        foreach (var c in humanoidCheck)
        {
            if (c && c.isHumanMotion)
            {
                requiresAnimator = true;
            }
        }
        try
        {
            if (requiresAnimator == false)
            {
                var importer = GetImporter(GetPrefabPath());
                if (importer && importer.animationType == ModelImporterAnimationType.Human)
                {
                    requiresAnimator = true;
                }
            }
        }
        catch { }
        try
        {
            if (requiresAnimator == false && IsOptimizedAnimator())
            {
                requiresAnimator = true;
            }
        }
        catch { }
        for (int i = 0; i < distinctClips.Count; i++)
        {
            if (bakeAnims.ContainsKey(distinctClips[i].name) == false)
            {
                bakeAnims.Add(distinctClips[i].name, true);
            }
        }
        return(distinctClips);
    }
示例#12
0
            public ParticleDetail(Object obj, ParticleChecker checker) : base(obj, checker)
            {
                Object[] dependencys = EditorUtility.CollectDependencies(new Object[] { obj });
                foreach (var o in dependencys)
                {
                    if (o is ParticleSystem)
                    {
                        ParticleSystem ps    = o as ParticleSystem;
                        ChildParticle  child = new ChildParticle();
                        child.name     = ps.name;
                        child.maxCount = (int)GetParticleEmissionCount(ps);
#if UNITY_5_5_OR_NEWER
                        child.maxSize = ps.emission.enabled ? ps.main.startSize.constantMax : 0;
#else
                        child.maxSize = ps.emission.enabled ? ps.startSize : 0;
#endif
                        child.psObject    = o;
                        child.active      = CheckIsRefObjectActive(ps.gameObject);
                        refObjectEnabled &= child.active;
                        childParticles.Add(child);
                    }
                    else if (o is TrailRenderer)
                    {
                        TrailRenderer      tr    = o as TrailRenderer;
                        ChildTrailRenderer child = new ChildTrailRenderer();
                        child.name = tr.name;
#if UNITY_5_5_OR_NEWER
                        child.minVertexDistance = tr.minVertexDistance;
#else
                        child.minVertexDistance = 0;
#endif
                        child.time        = tr.time;
                        child.trailObject = tr;
                        child.active      = CheckIsRefObjectActive(tr.gameObject);
                        refObjectEnabled &= child.active;
                        childTrails.Add(child);
                    }
                }
                //根物体最大粒子数等于相加总和
                int totalMaxCount = 0;
                foreach (var p in childParticles)
                {
                    totalMaxCount += p.maxCount;
                }
                checkMap.Add(checker.particleMaxCount, totalMaxCount);
                //根物体的大小等于子物体中最大的
                float totalMaxSize = 0.0f;
                foreach (var p in childParticles)
                {
                    if (p.maxSize > totalMaxSize)
                    {
                        totalMaxSize = p.maxSize;
                    }
                }
                checkMap.Add(checker.particleMaxSize, totalMaxSize);
                checkMap.Add(checker.particleComponentCount, childParticles.Count);
                checkMap.Add(checker.trailRendererCount, childTrails.Count);
                checkMap[checker.activeItem] = refObjectEnabled.ToString();
                //没有的不显示了
                if (childParticles.Count == 0 && childTrails.Count == 0)
                {
                    checker.CheckList.Remove(this);
                }
            }
示例#13
0
    public static bool GetAssetBundleCheck(Object[] objects, out CAssetBundleCheck abc)
    {
        HashSet <string> hsFileList = new HashSet <string>();

        abc = new CAssetBundleCheck();

        int i = 0;

        foreach (var ob in objects)
        {
            float s = (float)i / objects.Length;

            string collectDependenciesAssetPath = AssetDatabase.GetAssetPath(ob).ToLower();
            EditorUtility.DisplayProgressBar("CollectDependencies", collectDependenciesAssetPath, s);

            var dependencies = EditorUtility.CollectDependencies(new[] { ob });
            foreach (var o in dependencies)
            {
                if (o is TextAsset == false && o is GameObject == false && o is Texture2D == false && o is AudioClip == false)
                {
                    continue;
                }

                string assetPath = AssetDatabase.GetAssetPath(o).ToLower();
                if (hsFileList.Contains(assetPath) == false)
                {
                    //                    hsFileList.Add(assetPath);
                }
            }
            dependencies = null;
        }
        EditorUtility.ClearProgressBar();

        i         = 0;
        abc.count = (uint)hsFileList.Count;
        foreach (var fileName in hsFileList)
        {
            float s = (float)i / abc.count;
            EditorUtility.DisplayProgressBar("GetAssetBundleCheck", string.Format("Get asset bundle check {0}/{1}", i, abc.count), s);

            var path = System.Environment.CurrentDirectory + "/" + fileName;
            if (File.Exists(path) == false)
            {
                ++i;
                continue;
            }

            uint crc;
            if (MakeCRC.Make(path, out crc) == true)
            {
                abc.crc += crc;
            }
            FileInfo fi = new FileInfo(path);
            abc.size += (ulong)fi.Length;
            ++i;

            //            int totalMemory = System.GC.GetTotalMemory(true);
        }
        EditorUtility.ClearProgressBar();
        return(true);
    }
示例#14
0
        void CheckMeshes()
        {
            List <Mesh> meshesChecked = new List <Mesh>();

            foreach (MeshRenderer meshRenderer in Object.FindObjectsOfType <MeshRenderer>())
            {
                MeshFilter meshFilter = meshRenderer.GetComponent <MeshFilter>();
                if (meshFilter != null)
                {
                    Mesh mesh = meshFilter.sharedMesh;
                    if (mesh.tangents.Length > 0 && !meshesChecked.Contains(mesh))
                    {
                        meshesChecked.Add(mesh);
                        bool useBumpTexture = false;
                        var  dependencies   = EditorUtility.CollectDependencies(new UnityEngine.Object[] { meshRenderer });
                        foreach (Object obj in dependencies)
                        {
                            Texture2D texture = obj as Texture2D;
                            if (texture != null)
                            {
                                if (IsBumpTexture(texture))
                                {
                                    useBumpTexture = true;
                                    break;
                                }
                            }
                        }

                        if (!useBumpTexture)
                        {
                            Debug.Log(mesh.name + ":不需要导入切线数据", mesh);
                        }
                    }
                }
            }

            foreach (SkinnedMeshRenderer skinnedRenderer in Object.FindObjectsOfType <SkinnedMeshRenderer>())
            {
                Mesh mesh = skinnedRenderer.sharedMesh;
                if (mesh.tangents.Length > 0 && !meshesChecked.Contains(mesh))
                {
                    meshesChecked.Add(mesh);
                    bool useBumpTexture = false;
                    var  dependencies   = EditorUtility.CollectDependencies(new UnityEngine.Object[] { skinnedRenderer });
                    foreach (Object obj in dependencies)
                    {
                        Texture2D texture = obj as Texture2D;
                        if (texture != null)
                        {
                            if (IsBumpTexture(texture))
                            {
                                useBumpTexture = true;
                                break;
                            }
                        }
                    }

                    if (!useBumpTexture)
                    {
                        Debug.Log(mesh.name + ":不需要导入切线数据", mesh);
                    }
                }
            }

            foreach (Mesh mesh in meshesChecked)
            {
                if (mesh.colors.Length > 0)
                {
                    Debug.Log(mesh.name + ":含有顶点颜色,如果不需要可以使用“删除FBX顶点颜色”功能删除!", mesh);
                }
            }
        }
示例#15
0
 /// <summary>
 /// 获取所有相关资源
 /// </summary>
 /// <param name="go">目标对象</param>
 /// <returns>所有相关资源</returns>
 Object[] GetCorrelationResource(Object go)
 {
     Object[] roots = new Object[] { go };
     return(EditorUtility.CollectDependencies(roots));
 }
示例#16
0
        public static List <Object> CollectReverseDependencies(Object[] objs, string[] searchPaths = null)
        {
            var includeList = new HashSet <Object>();
            var stopWatch   = new Stopwatch();

            stopWatch.Start();

            var searchObjs = new HashSet <Object>();

            foreach (var guid in AssetDatabase.FindAssets(RevertDependenciesSearch, searchPaths))
            {
                var filePath = AssetDatabase.GUIDToAssetPath(guid);
                var mainObj  = AssetDatabase.LoadMainAssetAtPath(filePath);
                // EditorUtility.CollectDependencies 是 recursive 的
                if (searchObjs.Contains(mainObj))
                {
                    continue;
                }

                var hash = AssetDatabase.GetAssetDependencyHash(filePath);
                AssetDependenceObjects assetDepend;
                if (!AssetDependenceObjectDict.TryGetValue(filePath, out assetDepend))
                {
                    assetDepend = new AssetDependenceObjects();
                    AssetDependenceObjectDict[filePath] = assetDepend;
                }

                if (assetDepend.Hash != hash)
                {
                    assetDepend.Hash         = hash;
                    assetDepend.Dependencies =
                        EditorUtility.CollectDependencies(GetCacheSearchAsset(mainObj));
                }

                var dependencies = assetDepend.Dependencies;

                var isMatch = false;
                foreach (var dependence in dependencies)
                {
                    if (Array.IndexOf(objs, dependence) >= 0)
                    {
                        includeList.Add(mainObj);
                        isMatch = true;

                        break;
                    }
                }

                if (!isMatch)
                {
                    // 如果该对象没搜到,那该对象包含的对象都不需要搜了
                    searchObjs.UnionWith(dependencies);
                }
            }

            // 字体会错乱?
            AssetDatabase.Refresh();
            AssetDatabase.SaveAssets();

            stopWatch.Stop();
            UnityEngine.Debug.Log(String.Format("反向查找依赖耗时:{0}", stopWatch.Elapsed.Seconds));

            return(includeList.ToList());
        }
示例#17
0
 public static void ShowAllCorrelationResource()
 {
     Object[] roots = Selection.GetFiltered(typeof(Object), SelectionMode.Unfiltered);
     Selection.objects = EditorUtility.CollectDependencies(roots);
 }
示例#18
0
    void CheckResources()
    {
        //Debug.Log("CheckResources");

        ActiveTextures.Clear();
        ActiveMaterials.Clear();
        ActiveMeshDetails.Clear();
        ActiveShaderDetails.Clear();
        ActiveSoundDetails.Clear();

        foreach (LightmapData lightmap in LightmapSettings.lightmaps)
        {
            TryAddActiveTextures(lightmap.lightmapDir);
            TryAddActiveTextures(lightmap.lightmapColor);
        }

        Renderer[] renderers = (Renderer[])FindObjectsOfType(typeof(Renderer));
        foreach (Renderer renderer in renderers)
        {
            //Debug.Log("Renderer is "+renderer.name);
            foreach (Material material in renderer.sharedMaterials)
            {
                MaterialDetails tMaterialDetails = TryAddActiveMaterial(material);
                if (tMaterialDetails != null)
                {
                    tMaterialDetails.FoundInGameObjects.Add(renderer.gameObject);
                }

                ShaderDetails tShaderDetails = TryAddActiveShader(material.shader);
                if (tShaderDetails != null)
                {
                    if (!tShaderDetails.FoundInGameObjects.Contains(renderer.gameObject))
                    {
                        tShaderDetails.FoundInGameObjects.Add(renderer.gameObject);
                    }
                }
            }

            // add the lightmap reference to the renderer
            if (renderer.lightmapIndex >= 0 && renderer.lightmapIndex < LightmapSettings.lightmaps.Length)
            {
                LightmapData   lightmap = LightmapSettings.lightmaps[renderer.lightmapIndex];
                TextureDetails lmNear   = FindTextureDetails(lightmap.lightmapDir);
                if (lmNear != null && !lmNear.FoundInRenderers.Contains(renderer))
                {
                    lmNear.FoundInRenderers.Add(renderer);
                }

                TextureDetails lmFar = FindTextureDetails(lightmap.lightmapColor);
                if (lmFar != null && !lmFar.FoundInRenderers.Contains(renderer))
                {
                    lmFar.FoundInRenderers.Add(renderer);
                }
            }
        }

        foreach (MaterialDetails tMaterialDetails in ActiveMaterials)
        {
            Material tMaterial = tMaterialDetails.material;
            foreach (Object obj in EditorUtility.CollectDependencies(new UnityEngine.Object[] { tMaterial }))
            {
                if (obj is Texture)
                {
                    Texture        tTexture        = obj as Texture;
                    TextureDetails tTextureDetails = TryAddActiveTextures(tTexture);
                    tTextureDetails.FoundInMaterials.Add(tMaterial);
                }
                if (obj is Shader)
                {
                    Shader        shader        = obj as Shader;
                    ShaderDetails shaderDetails = TryAddActiveShader(shader);
                    if (!shaderDetails.FoundInMaterials.Contains(tMaterial))
                    {
                        shaderDetails.FoundInMaterials.Add(tMaterial);
                    }
                }
            }
        }

        MeshFilter[] meshFilters = (MeshFilter[])FindObjectsOfType(typeof(MeshFilter));
        foreach (MeshFilter tMeshFilter in meshFilters)
        {
            Mesh tMesh = tMeshFilter.sharedMesh;
            if (tMesh != null)
            {
                MeshDetails details = TryAddActiveMesh(tMesh);
                if (!details.FoundInGameObjects.Contains(tMeshFilter.gameObject))
                {
                    details.FoundInGameObjects.Add(tMeshFilter.gameObject);
                }
            }
        }

        Light[] lights = (Light[])FindObjectsOfType(typeof(Light));
        foreach (Light light in lights)
        {
            if (light.cookie)
            {
                TextureDetails details = TryAddActiveTextures(light.cookie);
                if (!details.FoundInLights.Contains(light))
                {
                    details.FoundInLights.Add(light);
                }
            }
        }

        GameObject[] gameObjs = (GameObject[])FindObjectsOfType(typeof(GameObject));
        foreach (GameObject obj in gameObjs)
        {
            foreach (Object o in EditorUtility.CollectDependencies(new UnityEngine.Object[] { obj }))
            {
                if (o is AudioClip)
                {
                    AudioClip    clip    = o as AudioClip;
                    SoundDetails details = TryAddAudioClip(clip);
                    if (!details.FoundInGameObjects.Contains(obj))
                    {
                        details.FoundInGameObjects.Add(obj);
                    }
                }
                if (o is MonoScript)
                {
                    MonoScript    script  = o as MonoScript;
                    ScriptDetails details = TryAddScript(script);
                    if (!details.FoundInGameObjects.Contains(obj))
                    {
                        details.FoundInGameObjects.Add(obj);
                    }
                }
            }
        }

        TotalTextureMemory = 0;
        foreach (TextureDetails tTextureDetails in ActiveTextures)
        {
            TotalTextureMemory += tTextureDetails.memSizeBytes;
        }

        TotalMeshVertices = 0;
        foreach (MeshDetails tMeshDetails in ActiveMeshDetails)
        {
            TotalMeshVertices += tMeshDetails.mesh.vertexCount;
        }

        // Sort by size, descending
        ActiveTextures.Sort(delegate(TextureDetails details1, TextureDetails details2) { return(details2.memSizeBytes - details1.memSizeBytes); });
        ActiveMeshDetails.Sort(delegate(MeshDetails details1, MeshDetails details2) { return(details2.mesh.vertexCount - details1.mesh.vertexCount); });
    }
示例#19
0
        // Token: 0x06000187 RID: 391 RVA: 0x0000BA4C File Offset: 0x00009C4C
        public static FindAssetUsage.Result InProject(IEnumerable <Object> findobjs, IEnumerable <Type> findtypes)
        {
            EditorUtility2.UnloadUnusedAssetsImmediate();
            Dictionary <Object, Dictionary <string, string> > dictionary = new Dictionary <Object, Dictionary <string, string> >();

            foreach (Object @object in findobjs)
            {
                if (@object != null && !dictionary.ContainsKey(@object))
                {
                    dictionary.Add(@object, new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase));
                }
            }
            string text = "";

            foreach (Type type in findtypes)
            {
                if (!string.IsNullOrEmpty(text))
                {
                    text += ", ";
                }
                text += type.Name;
            }
            using (EditorGUI2.ModalProgressBar modalProgressBar = new EditorGUI2.ModalProgressBar(string.Format("Searching {0} assets...", text), true))
            {
                List <string> pathsByType = AssetDatabase2.GetPathsByType(findtypes);
                for (int i = 0; i < pathsByType.Count; i++)
                {
                    string text2 = pathsByType[i];
                    if (modalProgressBar.TotalElapsedTime > 1f && modalProgressBar.ElapsedTime > 0.1f)
                    {
                        float  progress = (float)i / (float)pathsByType.Count;
                        string text3    = string.Format("[{1} remaining] {0}", FileUtil2.GetFileNameWithoutExtension(text2), pathsByType.Count - i - 1);
                        if (modalProgressBar.Update(text3, progress))
                        {
                            break;
                        }
                    }
                    Object   object2 = AssetDatabase.LoadMainAssetAtPath(text2);
                    Object[] array   = EditorUtility.CollectDependencies(new Object[]
                    {
                        object2
                    });
                    foreach (Object object3 in array)
                    {
                        Dictionary <string, string> dictionary2;
                        if (!(object3 == null) && dictionary.TryGetValue(object3, out dictionary2))
                        {
                            dictionary2[text2] = text2;
                        }
                    }
                    if (i % 25 == 0)
                    {
                        EditorUtility2.UnloadUnusedAssetsImmediate();
                    }
                }
            }
            FindAssetUsage.Result result = new FindAssetUsage.Result();
            foreach (KeyValuePair <Object, Dictionary <string, string> > keyValuePair in dictionary)
            {
                FindAssetUsage.ResultEntry resultEntry = new FindAssetUsage.ResultEntry();
                resultEntry.Asset = keyValuePair.Key;
                foreach (KeyValuePair <string, string> keyValuePair2 in keyValuePair.Value)
                {
                    resultEntry.Add(keyValuePair2.Key);
                }
                result.Entries.Add(resultEntry);
            }
            return(result);
        }
示例#20
0
        /// Finds references to passed objects and puts them in m_references
        void FindObjectReferences(Object toFind)
        {
            EditorUtility.DisplayProgressBar("Searching", "Generating file paths", 0.0f);

            //
            // Get all prefabs in the project
            //
            if (m_paths == null)
            {
                m_paths = new List <string>();
                GetFilePaths("Assets", ".prefab", ref m_paths);
            }

            float progressBarPos     = 0;
            int   numPaths           = m_paths.Count;
            int   hundredthIteration = MathEx.Max(1, numPaths / 100);    // So we only update progress bar 100 times, not for every item

            string toFindName = AssetDatabase.GetAssetPath(toFind);

            toFindName = System.IO.Path.GetFileNameWithoutExtension(toFindName);
            Object[] tmpArray = new Object[1];
            m_references.Clear();

            //
            // Loop through all files, and add any that have the selected object in it's list of dependencies
            //
            for (int i = 0; i < numPaths; ++i)
            {
                tmpArray[0] = AssetDatabase.LoadMainAssetAtPath(m_paths[i]);
                if (tmpArray != null && tmpArray.Length > 0 && tmpArray[0] != toFind)              // Don't add self
                {
                    Object[] dependencies = EditorUtility.CollectDependencies(tmpArray);
                    if (System.Array.Exists(dependencies, item => item == toFind))
                    {
                        // Don't add if another of the dependencies is already in there
                        m_references.Add(tmpArray[0] as GameObject);
                    }
                }
                if (i % hundredthIteration == 0)
                {
                    progressBarPos += 0.01f;
                    EditorUtility.DisplayProgressBar("Searching", "Searching dependencies", progressBarPos);
                }
            }

            EditorUtility.DisplayProgressBar("Searching", "Removing redundant references", 1);

            //
            // Go through the references, get dependencies of each and remove any that have another dependency on the match list. We only want direct dependencies.
            //
            for (int i = m_references.Count - 1; i >= 0; i--)
            {
                tmpArray[0] = m_references[i];
                Object[] dependencies = EditorUtility.CollectDependencies(tmpArray);

                bool shouldRemove = false;

                for (int j = 0; j < dependencies.Length && shouldRemove == false; ++j)
                {
                    Object dependency = dependencies[j];
                    shouldRemove = (m_references.Find(item => item == dependency && item != tmpArray[0]) != null);
                }

                if (shouldRemove)
                {
                    m_references.RemoveAt(i);
                }
            }

            EditorUtility.ClearProgressBar();
        }
示例#21
0
    void OnGUI()
    {
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos,
                                                    false,
                                                    false,
                                                    GUILayout.Width(Screen.width),
                                                    GUILayout.Height(Screen.height - EditorGUIUtility.singleLineHeight * 1.5f));
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.BeginVertical();
        GUILayout.Label("Used Files");
        if (usedObjects.Count > 0)
        {
            for (int i = 0; i < usedObjects.Count; i++)
            {
                EditorGUILayout.ObjectField(usedObjects[i], typeof(Object), true);
            }
        }
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical();
        GUILayout.Label("");
        if (usedObjects.Count > 0)
        {
            for (int i = 0; i < usedObjects.Count; i++)
            {
                if (GUILayout.Button("Select", GUILayout.Height(EditorGUIUtility.singleLineHeight / 1.07f)))
                {
                    Selection.activeObject = usedObjects[i];
                }
            }
        }
        EditorGUILayout.EndVertical();
        GUILayout.FlexibleSpace();
        if (true && allFilesList.Count > 0)
        {
            EditorGUILayout.BeginVertical();
            GUILayout.Label("");
            GUILayout.Box("", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(EditorGUIUtility.singleLineHeight * allFilesPaths.Length) });
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical();
            GUILayout.Label("");
            if (fileSize.Count > 0)
            {
                for (int i = 0; i < fileSize.Count; i++)
                {
                    GUILayout.Label(fileSize[i]);
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical();
            GUILayout.Label("");
            if (allFilesList.Count > 0)
            {
                for (int i = 0; i < allFilesList.Count; i++)
                {
                    if (GUILayout.Button("Delete", GUILayout.Height(EditorGUIUtility.singleLineHeight / 1.07f)))
                    {
                        FileUtil.DeleteFileOrDirectory(allFilesPaths[i]);
                        AssetDatabase.Refresh();
                    }
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical();
            GUILayout.Label("All Files");
            if (allFilesList.Count > 0)
            {
                for (int i = 0; i < allFilesList.Count; i++)
                {
                    if (usedObjects.Count > 0)
                    {
                        if (!usedObjects.Contains(allFilesList[i]))
                        {
                            GUI.backgroundColor = Color.red;
                        }
                        else
                        {
                            GUI.backgroundColor = Color.white;
                        }
                    }
                    EditorGUILayout.ObjectField(allFilesList[i], typeof(Object), true);
                }
            }
            GUI.backgroundColor = Color.white;
            EditorGUILayout.EndVertical();
        }

        EditorGUILayout.EndHorizontal();

        GUILayout.FlexibleSpace();
        if (GUILayout.Button("ShowAllUsedFiles"))
        {
            usedFiles.Clear();
            usedObjects.Clear();
            objects.Clear();
            scenes = EditorBuildSettings.scenes;
            for (int i = 0; i < scenes.Length; i++)
            {
                objects.Add(AssetDatabase.LoadAssetAtPath(scenes[i].path, typeof(Object)));
                usedObjects.Add(AssetDatabase.LoadAssetAtPath(scenes[i].path, typeof(Object)));
            }

            Object[] collectedFiles = EditorUtility.CollectDependencies(objects.ToArray());
            for (int i = 0; i < collectedFiles.Length; i++)
            {
                string path = AssetDatabase.GetAssetPath(collectedFiles[i]);
                if (path.Contains("Asset"))
                {
                    //if (!CheckFilePath(path))
                    //{
                    if (CheckType(collectedFiles[i]))
                    {
                        if (!usedFiles.Contains(path))
                        {
                            usedFiles.Add(path);
                            Object t = (Object)AssetDatabase.LoadAssetAtPath(path, typeof(Object));
                            usedObjects.Add(t);
                        }
                    }
                    //}
                }
            }
        }

        if (GUILayout.Button("GetAllFiles"))
        {
            fileSize.Clear();
            allFilesList.Clear();
            string[]      info      = Directory.GetFiles("Assets", "*.*", SearchOption.AllDirectories);
            List <string> infoPaths = new List <string>();
            infoPaths = info.ToList();
            for (int o = 0; o < infoPaths.Count; o++)
            {
                if (CheckIgnoreContains(infoPaths[o]))
                {
                    infoPaths.Remove(infoPaths[o]);
                    o--;
                }
            }
            allFilesPaths = new string[infoPaths.Count];
            for (int i = 0; i < allFilesPaths.Length; i++)
            {
                allFilesPaths[i] = infoPaths[i];
                Object t = (Object)AssetDatabase.LoadAssetAtPath(allFilesPaths[i], typeof(Object));
                allFilesList.Add(t);
                FileInfo fileInfo = new FileInfo(infoPaths[i]);
                //float size = ((int)(fileInfo.Length) / 100f;
                fileSize.Add((fileInfo.Length / 1000000f).ToString() + " mb");
            }
        }

        if (GUILayout.Button("Clear"))
        {
            fileSize.Clear();
            allFilesList.Clear();
            usedFiles.Clear();
            usedObjects.Clear();
            objects.Clear();
            scenes = new EditorBuildSettingsScene[0];
        }
        EditorGUILayout.EndScrollView();
    }
示例#22
0
 public static ImmutableList <Object> collectDependencies(Object[] roots) =>
 EditorUtility.CollectDependencies(roots)
 .Where(o => o is GameObject || o is ScriptableObject)
 .Distinct()
 .ToImmutableList();
    public static bool PackageAllPrefab(UnityEditor.BuildTarget target, List <string> ignoreFilelist, UnityEngine.Object SelectObject = null)
    {
        string SavePath = "";
        //try
        //{
        //	SavePath = PlatformMap.GetPlatformPath(target) + "/" + VersionManager.GetCurVersion(target)+ "/";
        //}
        //catch(IOException exp)
        //{
        //	EditorUtility.DisplayDialog("Error", exp.Message, "OK");
        //	return false;
        //}

        string SelectPath = "Assets/";

        string [] files = null;
        if (SelectObject != null)
        {
            //打包一个预设文件.
            SelectPath = AssetDatabase.GetAssetPath(SelectObject);
            PackageOnePrefab(target, SelectObject);
            AssetDatabase.Refresh();
            return(true);
        }
        else
        {
            try
            {
                files = Directory.GetFiles(SelectPath, "*.prefab", SearchOption.AllDirectories);
            }
            catch (Exception exp)
            {
                UnityEngine.Debug.LogError(exp.Message);
            }
            strBuilded.Clear();
        }

        int packagefile   = 0;
        int unpackagefile = 0;

        foreach (string eachfile in files)
        {
            string file = eachfile.Replace('\\', '/');
            string path = file;
            if (ignoreFilelist != null)
            {
                bool   bIgnore    = false;
                string name       = "";
                int    nNameBegin = path.LastIndexOf('/');
                int    nNameEnd   = path.LastIndexOf('.');
                name = path.Substring(nNameBegin + 1, nNameEnd - nNameBegin - 1);
                foreach (string strIgnore in ignoreFilelist)
                {
                    if (name == strIgnore)
                    {
                        bIgnore = true;
                        break;
                    }
                }

                if (bIgnore)
                {
                    unpackagefile++;
                    continue;
                }
            }
            packagefile++;
            path  = SavePath + path;
            path  = path.Substring(0, path.LastIndexOf('.'));
            path += ".assetbundle";
            if (strBuilded.Contains(file))
            {
                continue;
            }
            UnityEngine.Object o = AssetDatabase.LoadMainAssetAtPath(file);
            BuildPipeline.BuildAssetBundle(o, null, path, BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.DeterministicAssetBundle | BuildAssetBundleOptions.CollectDependencies, target);
            strBuilded.Add(file);
            UnityEngine.Object[] depend = EditorUtility.CollectDependencies(new UnityEngine.Object[] { o });
            foreach (UnityEngine.Object inner in depend)
            {
                string str = AssetDatabase.GetAssetPath(inner);
                if (str.EndsWith(".cs") || str == "")
                {
                    continue;
                }
                if (str == file)
                {
                    continue;
                }
                if (inner != null)
                {
                    PackageOnePrefab(target, inner);
                }
            }
        }
        EditorUtility.DisplayDialog("Tip", "Package file : " + packagefile.ToString() + "\r\nunPackage file : " + unpackagefile.ToString(), "OK");
        AssetDatabase.Refresh();
        return(true);
    }
 /// <summary>
 /// 获取所有相关资源
 /// </summary>
 /// <param name="go">目标对象</param>
 /// <returns>所有相关资源</returns>
 static UnityEngine.Object[] GetCorrelationResource(UnityEngine.Object go)
 {
     UnityEngine.Object[] roots = new UnityEngine.Object[] { go };
     return(EditorUtility.CollectDependencies(roots));
 }
示例#25
0
        private static void FixImageTypeToSliced()
        {
            var               referenceCache = new Dictionary <string, List <string> >();
            List <string>     spriteNames    = new List <string>();
            List <GameObject> references     = new List <GameObject>();
            List <string>     paths          = new List <string>();

            foreach (Object child in Selection.objects)
            {
                if (child != null)
                {
                    spriteNames.Add(child.name);
                }
            }

            if (spriteNames.Count == 0)
            {
                Debug.LogError("List sprites is empty!");
                return;
            }

            GetFilePaths("Assets", ".prefab", ref paths);

            //
            // Loop through all files, and add any that have the selected object in it's list of dependencies
            //
            Object[] tmpArray = new Object[1];
            references.Clear();

            foreach (Object child in Selection.objects)
            {
                for (int i = 0; i < paths.Count; ++i)
                {
                    tmpArray[0] = AssetDatabase.LoadMainAssetAtPath(paths[i]);
                    if (tmpArray != null && tmpArray.Length > 0 && tmpArray[0] != child) // Don't add self
                    {
                        Object[] dependencies = EditorUtility.CollectDependencies(tmpArray);
                        if (System.Array.Exists(dependencies, item => item == child))
                        {
                            // Don't add if another of the dependencies is already in there
                            references.Add(tmpArray[0] as GameObject);
                        }
                    }
                }
            }

            //
            // Go through the references, get dependencies of each and remove any that have another dependency on the match list. We only want direct dependencies.
            //
            for (int i = references.Count - 1; i >= 0; i--)
            {
                tmpArray[0] = references[i];
                Object[] dependencies = EditorUtility.CollectDependencies(tmpArray);

                bool shouldRemove = false;

                for (int j = 0; j < dependencies.Length && shouldRemove == false; ++j)
                {
                    Object dependency = dependencies[j];
                    shouldRemove = (references.Find(item => item == dependency && item != tmpArray[0]) != null);
                }

                if (shouldRemove)
                {
                    references.RemoveAt(i);
                }
            }

            List <Image> imgs;

            foreach (GameObject gm in references)
            {
                imgs = GetImage(gm.transform, spriteNames);
                foreach (Image im in imgs)
                {
                    if (im.type == Image.Type.Simple)
                    {
                        im.type = Image.Type.Sliced;
                    }
                }
                imgs.Clear();
            }
            references.Clear();
            //referenceCache.Clear();

            Debug.Log("***Fix Done***");
        }
示例#26
0
    private static void CreateAssetBundleDat(AssetBundleManifest manifest, BuildAssetBundleOptions _buildOptions, BuildTarget _buildTarget)
    {
        if (manifest == null)
        {
            return;
        }

        string[] abs = manifest.GetAllAssetBundles();

        AssetBundle[] aaaa = new AssetBundle[abs.Length];

        try{
            List <UnityEngine.Object> assets = new List <UnityEngine.Object> ();

            List <string> assetNames = new List <string> ();

            List <string> assetBundleNames = new List <string> ();

            Dictionary <string, List <string> > result = new Dictionary <string, List <string> > ();

            for (int i = 0; i < abs.Length; i++)
            {
                AssetBundle ab = LoadAssetBundle("file:///" + Application.streamingAssetsPath + "/" + AssetBundleManager.path + abs[i]);

//				AssetBundle ab = AssetBundle.CreateFromFile(Application.streamingAssetsPath + "/" + AssetBundleManager.path + abs[i]);

                aaaa[i] = ab;

                string[] nn = ab.GetAllAssetNames();

                foreach (string str in nn)
                {
                    if (assetNames.Contains(str))
                    {
                        SuperDebug.LogError("error!");
                    }
                    else
                    {
                        assetNames.Add(str);

                        UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(str);

                        assets.Add(obj);

                        assetBundleNames.Add(abs[i]);

                        List <string> ll = new List <string>();

                        result.Add(str, ll);
                    }
                }
            }

            for (int i = 0; i < assetNames.Count; i++)
            {
                string             name = assetNames[i];
                UnityEngine.Object obj  = assets[i];
                List <string>      list = result[name];

                UnityEngine.Object[] sss = EditorUtility.CollectDependencies(new UnityEngine.Object[] { obj });

                foreach (UnityEngine.Object dd in sss)
                {
                    if (dd != obj)
                    {
                        if (assets.Contains(dd))
                        {
                            string assetBundleName = assetBundleNames[assets.IndexOf(dd)];

                            if (!list.Contains(assetBundleName))
                            {
                                list.Add(assetBundleName);
                            }
                        }
                    }
                }
            }

            FileInfo fi = new FileInfo(Application.streamingAssetsPath + "/" + AssetManager.dataName);

            if (fi.Exists)
            {
                fi.Delete();
            }

            FileStream fs = fi.Create();

            BinaryWriter bw = new BinaryWriter(fs);

            AssetManagerDataFactory.SetData(bw, assetNames, assetBundleNames, result);

            fs.Flush();

            bw.Close();

            fs.Close();

            fs.Dispose();
        }catch (Exception e) {
            Debug.Log("error:" + e.Message);
        }finally{
            foreach (AssetBundle aaa in aaaa)
            {
                aaa.Unload(true);
            }
        }
    }
示例#27
0
        /// <summary>
        /// 分析引用关系
        /// </summary>
        public void Analyze()
        {
            if (_isAnalyzed)
            {
                return;
            }
            _isAnalyzed = true;

#if !UNITY_5
            LoadMetaHashIfNecessary();
#endif
            _cacheInfo     = AssetBundleUtils.GetCacheInfo(assetPath);
            _isFileChanged = _cacheInfo == null || !_cacheInfo.fileHash.Equals(GetHash()) || !_cacheInfo.metaHash.Equals(_metaHash);
            if (_cacheInfo != null)
            {
                _bundleCrc = _cacheInfo.bundleCrc;
                if (_isFileChanged)
                {
                    Debug.Log("File was changed : " + assetPath);
                }
            }

            Object[] deps = EditorUtility.CollectDependencies(new Object[] { asset });
#if UNITY_5
            List <Object> depList = new List <Object>();
            for (int i = 0; i < deps.Length; i++)
            {
                Object o = deps[i];
                //不包含脚本对象
                //不包含LightingDataAsset对象
                if (o is MonoScript || o is LightingDataAsset)
                {
                    continue;
                }

                //不包含builtin对象
                string path = AssetDatabase.GetAssetPath(o);
                if (path.StartsWith("Resources"))
                {
                    continue;
                }

                depList.Add(o);
            }
            deps = depList.ToArray();
#else
            //提取 resource.builtin
            for (int i = 0; i < deps.Length; i++)
            {
                Object dep  = deps[i];
                string path = AssetDatabase.GetAssetPath(dep);
                if (path.StartsWith("Resources"))
                {
                    AssetTarget builtinAsset = AssetBundleUtils.Load(dep);
                    this.AddDependParent(builtinAsset);
                    builtinAsset.Analyze();
                }
            }
#endif

            var res = from s in deps
                      let obj = AssetDatabase.GetAssetPath(s)
                                select obj;
            var paths = res.Distinct().ToArray();

            for (int i = 0; i < paths.Length; i++)
            {
                if (File.Exists(paths[i]) == false)
                {
                    //Debug.Log("invalid:" + paths[i]);
                    continue;
                }
                FileInfo    fi     = new FileInfo(paths[i]);
                AssetTarget target = AssetBundleUtils.Load(fi);
                if (target == null)
                {
                    continue;
                }

                this.AddDependParent(target);

                target.Analyze();
            }
        }
示例#28
0
    void CheckResources()
    {
        ActiveTextures.Clear();
        ActiveMaterials.Clear();
        ActiveMeshDetails.Clear();

        Renderer[] renderers = FindObjects <Renderer>();

        //Debug.Log("Total renderers "+renderers.Length);
        foreach (Renderer renderer in renderers)
        {
            //Debug.Log("Renderer is "+renderer.name);
            foreach (Material material in renderer.sharedMaterials)
            {
                MaterialDetails tMaterialDetails = FindMaterialDetails(material);
                if (tMaterialDetails == null)
                {
                    tMaterialDetails          = new MaterialDetails();
                    tMaterialDetails.material = material;
                    ActiveMaterials.Add(tMaterialDetails);
                }
                tMaterialDetails.FoundInRenderers.Add(renderer);
            }

            if (renderer is SpriteRenderer)
            {
                SpriteRenderer tSpriteRenderer = (SpriteRenderer)renderer;

                if (tSpriteRenderer.sprite != null)
                {
                    var tSpriteTextureDetail = GetTextureDetail(tSpriteRenderer.sprite.texture, renderer);
                    if (!ActiveTextures.Contains(tSpriteTextureDetail))
                    {
                        ActiveTextures.Add(tSpriteTextureDetail);
                    }
                }
            }
        }

        foreach (MaterialDetails tMaterialDetails in ActiveMaterials)
        {
            Material tMaterial = tMaterialDetails.material;
            if (tMaterial != null)
            {
                var dependencies = EditorUtility.CollectDependencies(new UnityEngine.Object[] { tMaterial });
                foreach (Object obj in dependencies)
                {
                    if (obj is Texture)
                    {
                        Texture tTexture       = obj as Texture;
                        var     tTextureDetail = GetTextureDetail(tTexture, tMaterial, tMaterialDetails);
                        ActiveTextures.Add(tTextureDetail);
                    }
                }

                //if the texture was downloaded, it won't be included in the editor dependencies
                if (tMaterial.mainTexture != null && !dependencies.Contains(tMaterial.mainTexture))
                {
                    var tTextureDetail = GetTextureDetail(tMaterial.mainTexture, tMaterial, tMaterialDetails);
                    ActiveTextures.Add(tTextureDetail);
                }
            }
        }


        MeshFilter[] meshFilters = FindObjects <MeshFilter>();

        foreach (MeshFilter tMeshFilter in meshFilters)
        {
            Mesh tMesh = tMeshFilter.sharedMesh;
            if (tMesh != null)
            {
                MeshDetails tMeshDetails = FindMeshDetails(tMesh);
                if (tMeshDetails == null)
                {
                    tMeshDetails      = new MeshDetails();
                    tMeshDetails.mesh = tMesh;
                    ActiveMeshDetails.Add(tMeshDetails);
                }
                tMeshDetails.FoundInMeshFilters.Add(tMeshFilter);
            }
        }

        SkinnedMeshRenderer[] skinnedMeshRenderers = FindObjects <SkinnedMeshRenderer>();

        foreach (SkinnedMeshRenderer tSkinnedMeshRenderer in skinnedMeshRenderers)
        {
            Mesh tMesh = tSkinnedMeshRenderer.sharedMesh;
            if (tMesh != null)
            {
                MeshDetails tMeshDetails = FindMeshDetails(tMesh);
                if (tMeshDetails == null)
                {
                    tMeshDetails      = new MeshDetails();
                    tMeshDetails.mesh = tMesh;
                    ActiveMeshDetails.Add(tMeshDetails);
                }
                tMeshDetails.FoundInSkinnedMeshRenderer.Add(tSkinnedMeshRenderer);
            }
        }

        if (IncludeSpriteAnimations)
        {
            Animator[] animators = FindObjects <Animator>();
            foreach (Animator anim in animators)
            {
#if UNITY_4_6 || UNITY_4_5 || UNITY_4_4 || UNITY_4_3 || UNITY_4_7
                UnityEditorInternal.AnimatorController ac = anim.runtimeAnimatorController as UnityEditorInternal.AnimatorController;
#elif UNITY_5
                UnityEditor.Animations.AnimatorController ac = anim.runtimeAnimatorController as UnityEditor.Animations.AnimatorController;
#endif

                for (int x = 0; x < anim.layerCount; x++)
                {
#if UNITY_4_6 || UNITY_4_5 || UNITY_4_4 || UNITY_4_3 || UNITY_4_7
                    UnityEditorInternal.StateMachine sm = ac.GetLayer(x).stateMachine;
                    int cnt = sm.stateCount;
#elif UNITY_5
                    UnityEditor.Animations.AnimatorStateMachine sm = ac.layers[x].stateMachine;
                    int cnt = sm.states.Length;
#endif

                    for (int i = 0; i < cnt; i++)
                    {
#if UNITY_4_6 || UNITY_4_5 || UNITY_4_4 || UNITY_4_3 || UNITY_4_7
                        UnityEditorInternal.State state = sm.GetState(i);
                        Motion m = state.GetMotion();
#elif UNITY_5
                        UnityEditor.Animations.AnimatorState state = sm.states[i].state;
                        Motion m = state.motion;
#endif
                        if (m != null)
                        {
                            AnimationClip clip = m as AnimationClip;

                            EditorCurveBinding[] ecbs = AnimationUtility.GetObjectReferenceCurveBindings(clip);

                            foreach (EditorCurveBinding ecb in ecbs)
                            {
                                if (ecb.propertyName == "m_Sprite")
                                {
                                    foreach (ObjectReferenceKeyframe keyframe in AnimationUtility.GetObjectReferenceCurve(clip, ecb))
                                    {
                                        Sprite tSprite = keyframe.value as Sprite;

                                        if (tSprite != null)
                                        {
                                            var tTextureDetail = GetTextureDetail(tSprite.texture, anim);
                                            if (!ActiveTextures.Contains(tTextureDetail))
                                            {
                                                ActiveTextures.Add(tTextureDetail);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        if (IncludeScriptReferences)
        {
            MonoBehaviour[] scripts = FindObjects <MonoBehaviour>();
            foreach (MonoBehaviour script in scripts)
            {
                BindingFlags flags  = BindingFlags.Public | BindingFlags.Instance; // only public non-static fields are bound to by Unity.
                FieldInfo[]  fields = script.GetType().GetFields(flags);

                foreach (FieldInfo field in fields)
                {
                    System.Type fieldType = field.FieldType;
                    if (fieldType == typeof(Sprite))
                    {
                        Sprite tSprite = field.GetValue(script) as Sprite;
                        if (tSprite != null)
                        {
                            var tSpriteTextureDetail = GetTextureDetail(tSprite.texture, script);
                            if (!ActiveTextures.Contains(tSpriteTextureDetail))
                            {
                                ActiveTextures.Add(tSpriteTextureDetail);
                            }
                        }
                    }
                }
            }
        }

        TotalTextureMemory = 0;
        foreach (TextureDetails tTextureDetails in ActiveTextures)
        {
            TotalTextureMemory += tTextureDetails.memSizeKB;
        }

        TotalMeshVertices = 0;
        foreach (MeshDetails tMeshDetails in ActiveMeshDetails)
        {
            TotalMeshVertices += tMeshDetails.mesh.vertexCount;
        }

        // Sort by size, descending
        ActiveTextures.Sort(delegate(TextureDetails details1, TextureDetails details2) { return(details2.memSizeKB - details1.memSizeKB); });
        ActiveMeshDetails.Sort(delegate(MeshDetails details1, MeshDetails details2) { return(details2.mesh.vertexCount - details1.mesh.vertexCount); });
    }
示例#29
0
        private void GetUsingObjects()
        {
            #region clear
            m_objectMap.Clear();
            foreach (var dt in SampleDataDict)
            {
                dt.Value.objects.Clear();
                dt.Value.totalSize      = 0;
                dt.Value.scrollPosition = Vector2.zero;
            }
            System.GC.Collect();
            //Resources.UnloadUnusedAssets();
            EditorUtility.UnloadUnusedAssetsImmediate();
            #endregion

            #region get using gameObject
            List <GameObject> list = new List <GameObject>();
            GameObject[]      gos  = Resources.FindObjectsOfTypeAll <GameObject>();
            foreach (var go in gos)
            {
                if (!EditorUtility.IsPersistent(go.transform.root.gameObject))
                {
                    continue;
                }
                if ((go.hideFlags & HideFlags.DontSaveInBuild) == HideFlags.DontSaveInBuild)
                {
                    continue;
                }
                if (go.hideFlags == HideFlags.NotEditable || go.hideFlags == HideFlags.HideAndDontSave)
                {
                    continue;
                }
                list.Add(go);
            }
            #endregion

            foreach (var go in list)
            {
                if (go.transform.parent != null)
                {
                    continue;
                }
                Object[] des = EditorUtility.CollectDependencies(new Object[] { go });
                foreach (var dt in SampleDataDict)
                {
                    TakeSamples(des, dt.Key, dt.Value, go);
                }
            }

            foreach (var dt in SampleDataDict)
            {
                dt.Value.objects.Sort((a, b) => {
                    int aIn    = a.isInScene ? 1 : 0;
                    int bIn    = b.isInScene ? 1 : 0;
                    int result = 0;
                    if (aIn != bIn)
                    {
                        result = aIn - bIn;
                    }
                    else
                    {
                        result = b.size - a.size;
                    }
                    return(result);
                });
            }
        }
示例#30
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////
    // 导出带有目录结构的非依赖Prefab
    /////////////////////////////////////////////////////////////////////////////////////////////////////
    static void ExportNoneEffectPrefab(string selectPath, string choosePath, string loadPath, BuildTarget buildTarget, string[] fileEndArray, string effectName, bool isShader = false, bool isPrefab = false)
    {
        string startPath = selectPath.Substring(0, selectPath.IndexOf(choosePath) + choosePath.Length).Replace("\\", "/");

        Debug.Log("==startPath:" + startPath);
        // 获取 文件名:路径 字典
        Dictionary <string, string> singlePrefabs = GetPrefabDicInPath(Application.dataPath + startPath, fileEndArray);

        // 获取 文件名:物体 字典
        Dictionary <string, Object> singleObjsDic = GetFolderObjectDicByPathGroup(singlePrefabs, selectPath);

        // 去掉等级标识后的路径
        Dictionary <string, Object> finalObjsDic = new Dictionary <string, Object>();

        // 获取所有文件名对应的等级
        foreach (KeyValuePair <string, string> curObjPath in singlePrefabs)
        {
            string curKey = curObjPath.Key;
            if (!singleObjsDic.ContainsKey(curKey))
            {
                Debug.LogError(curKey);
                continue;
            }

            curKey = RecordSourceLevel(curKey, startPath, curObjPath.Value, loadPath);
            finalObjsDic.Add(curKey, singleObjsDic[curObjPath.Key]);
        }

        Object[] curLoadPrefab      = new Object[finalObjsDic.Count];
        int      curLoadPrefabIndex = 0;

        foreach (KeyValuePair <string, Object> obj in finalObjsDic)
        {
            curLoadPrefab[curLoadPrefabIndex++] = obj.Value;
        }

        Object[]      dependObjs       = EditorUtility.CollectDependencies(curLoadPrefab);
        List <Object> shaderDependObjs = new List <Object>();

        foreach (Object curDepend in dependObjs)
        {
            if (curDepend is UnityEngine.Shader)
            {
//                string shaderPath = AssetDatabase.GetAssetPath(curDepend);
                //if (shaderPath.Contains("Assets/MLDJ"))
                {
                    //if (curDepend.name.IndexOf("OutLineHighLightSelfIllumVirtualLightDir") >= 0)
                    //{
                    //    continue;
                    //}

                    shaderDependObjs.Add(curDepend);
                }
            }
        }

        BuildAssetBundleOptions optionsDepend =
            BuildAssetBundleOptions.DeterministicAssetBundle |
            BuildAssetBundleOptions.CompleteAssets;
        BuildAssetBundleOptions optionsNormal =
            BuildAssetBundleOptions.DeterministicAssetBundle |
            BuildAssetBundleOptions.CollectDependencies;

        BuildPipeline.PushAssetDependencies();


        Object[] finalDependObj = null;
        if (shaderDependObjs.Count > 0 && !isPrefab)
        {
            finalDependObj = new Object[shaderDependObjs.Count];
            for (int i = 0; i < shaderDependObjs.Count; i++)
            {
                finalDependObj[i] = shaderDependObjs[i];
            }
        }

        if (finalDependObj != null)
        {
            //model_shader_common

            string outputPath = loadPath + "/" + effectName + ".data";
            Utils.CheckTargetPath(outputPath);
            BuildPipeline.BuildAssetBundle(null, finalDependObj, outputPath, optionsDepend, buildTarget);
        }

        if (!isShader)
        {
            // 生成所有物体
            foreach (KeyValuePair <string, Object> obj in finalObjsDic)
            {
                Debug.Log("objKey:" + obj.Key);
                Debug.Log("loadPath:" + loadPath);
                string outputPath = loadPath + "/" + obj.Key + ".data";
                Utils.CheckTargetPath(outputPath);
                BuildPipeline.PushAssetDependencies();
                BuildPipeline.BuildAssetBundle(obj.Value, null, outputPath, optionsNormal, buildTarget);
                BuildPipeline.PopAssetDependencies();
            }
        }

        BuildPipeline.PopAssetDependencies();
    }