コード例 #1
0
        public AssetBundleAnalyzerController(AssetBundleCollection assetBundleCollection)
        {
            m_AssetBundleCollection = (assetBundleCollection != null ? assetBundleCollection : new AssetBundleCollection());

            m_AssetBundleCollection.OnLoadingAssetBundle += delegate(int index, int count)
            {
                if (OnLoadingAssetBundle != null)
                {
                    OnLoadingAssetBundle(index, count);
                }
            };

            m_AssetBundleCollection.OnLoadingAsset += delegate(int index, int count)
            {
                if (OnLoadingAsset != null)
                {
                    OnLoadingAsset(index, count);
                }
            };

            m_AssetBundleCollection.OnLoadCompleted += delegate()
            {
                if (OnLoadCompleted != null)
                {
                    OnLoadCompleted();
                }
            };

            m_DependencyDatas         = new Dictionary <string, DependencyData>();
            m_ScatteredAssets         = new Dictionary <string, List <Asset> >();
            m_AnalyzedStamps          = new HashSet <Stamp>();
            m_CircularDependencyDatas = new List <string[]>();
        }
コード例 #2
0
        public AssetBundleEditorController()
        {
            m_ConfigurationPath = Type.GetConfigurationPath <AssetBundleEditorConfigPathAttribute>() ?? Utility.Path.GetCombinePath(Application.dataPath, "GameFramework/Configs/AssetBundleEditor.xml");

            m_AssetBundleCollection = new AssetBundleCollection();

            m_AssetBundleCollection.OnLoadingAssetBundle += delegate(int index, int count)
            {
                if (OnLoadingAssetBundle != null)
                {
                    OnLoadingAssetBundle(index, count);
                }
            };

            m_AssetBundleCollection.OnLoadingAsset += delegate(int index, int count)
            {
                if (OnLoadingAsset != null)
                {
                    OnLoadingAsset(index, count);
                }
            };

            m_AssetBundleCollection.OnLoadCompleted += delegate()
            {
                if (OnLoadCompleted != null)
                {
                    OnLoadCompleted();
                }
            };

            m_SourceAssetSearchPaths         = new List <string>();
            m_SourceAssetSearchRelativePaths = new List <string>();
            m_SourceAssets                 = new Dictionary <string, SourceAsset>();
            m_SourceAssetRoot              = null;
            m_SourceAssetRootPath          = null;
            m_SourceAssetUnionTypeFilter   = null;
            m_SourceAssetUnionLabelFilter  = null;
            m_SourceAssetExceptTypeFilter  = null;
            m_SourceAssetExceptLabelFilter = null;
            m_AssetSorter = AssetSorterType.Path;

            SourceAssetRootPath = DefaultSourceAssetRootPath;
        }
コード例 #3
0
        public AssetBundleEditorController()
        {
            m_AssetBundleCollection = new AssetBundleCollection();
            m_AssetBundleCollection.OnLoadingAssetBundle += delegate(int index, int count) { OnLoadingAssetBundle?.Invoke(index, count); };
            m_AssetBundleCollection.OnLoadingAsset       += delegate(int index, int count) { OnLoadingAsset?.Invoke(index, count); };
            m_AssetBundleCollection.OnLoadCompleted      += delegate() { OnLoadCompleted?.Invoke(); };

            m_SourceAssetSearchPaths         = new List <string>();
            m_SourceAssetSearchRelativePaths = new List <string>();
            m_SourceAssets                 = new Dictionary <string, SourceAsset>();
            m_SourceAssetRoot              = null;
            m_SourceAssetRootPath          = null;
            m_SourceAssetUnionTypeFilter   = null;
            m_SourceAssetUnionLabelFilter  = null;
            m_SourceAssetExceptTypeFilter  = null;
            m_SourceAssetExceptLabelFilter = null;
            m_AssetSorter = AssetSorterType.Path;

            SourceAssetRootPath = DefaultSourceAssetRootPath;
        }
        public bool SyncFromProject()
        {
            AssetBundleCollection assetBundleCollection = new AssetBundleCollection();

            string[] assetBundleNames = GetUsedAssetBundleNames();
            foreach (string assetBundleFullName in assetBundleNames)
            {
                string assetBundleName    = assetBundleFullName;
                string assetBundleVariant = null;
                int    dotPosition        = assetBundleFullName.LastIndexOf('.');
                if (dotPosition > 0 && dotPosition < assetBundleFullName.Length - 1)
                {
                    assetBundleName    = assetBundleFullName.Substring(0, dotPosition);
                    assetBundleVariant = assetBundleFullName.Substring(dotPosition + 1);
                }

                if (!assetBundleCollection.AddAssetBundle(assetBundleName, assetBundleVariant, AssetBundleLoadType.LoadFromFile, false))
                {
                    return(false);
                }

                string[] assetNames = GetAssetPathsFromAssetBundle(assetBundleFullName);
                foreach (string assetName in assetNames)
                {
                    string assetGuid = AssetDatabase.AssetPathToGUID(assetName);
                    if (string.IsNullOrEmpty(assetGuid))
                    {
                        return(false);
                    }

                    if (!assetBundleCollection.AssignAsset(assetGuid, assetBundleName, assetBundleVariant))
                    {
                        return(false);
                    }
                }
            }

            return(assetBundleCollection.Save());
        }
        public bool SyncToProject()
        {
            AssetBundleCollection assetBundleCollection = new AssetBundleCollection();

            assetBundleCollection.OnLoadingAssetBundle += delegate(int index, int count)
            {
                if (OnLoadingAssetBundle != null)
                {
                    OnLoadingAssetBundle(index, count);
                }
            };

            assetBundleCollection.OnLoadingAsset += delegate(int index, int count)
            {
                if (OnLoadingAsset != null)
                {
                    OnLoadingAsset(index, count);
                }
            };

            assetBundleCollection.OnLoadCompleted += delegate()
            {
                if (OnCompleted != null)
                {
                    OnCompleted();
                }
            };

            if (!assetBundleCollection.Load())
            {
                return(false);
            }

            int assetIndex = 0;
            int assetCount = assetBundleCollection.AssetCount;

            AssetBundle[] assetBundles = assetBundleCollection.GetAssetBundles();
            foreach (AssetBundle assetBundle in assetBundles)
            {
                Asset[] assets = assetBundle.GetAssets();
                foreach (Asset asset in assets)
                {
                    AssetImporter assetImporter = AssetImporter.GetAtPath(asset.Name);
                    if (assetImporter == null)
                    {
                        if (OnCompleted != null)
                        {
                            OnCompleted();
                        }

                        return(false);
                    }

                    assetImporter.assetBundleName    = assetBundle.Name;
                    assetImporter.assetBundleVariant = assetBundle.Variant;
                    assetImporter.SaveAndReimport();

                    if (OnAssetBundleDataChanged != null)
                    {
                        OnAssetBundleDataChanged(++assetIndex, assetCount, asset.Name);
                    }
                }
            }

            if (OnCompleted != null)
            {
                OnCompleted();
            }

            return(true);
        }