예제 #1
0
 internal List <AssetInfo> GetDependencies()
 {
     //TODO - not sure this refreshes enough. need to build tests around that.
     if (m_dependencies == null)
     {
         m_dependencies = new List <AssetInfo>();
         if (AssetDatabase.IsValidFolder(m_FullAssetName))
         {
             //if we have a folder, its dependencies were already pulled in through alternate means.  no need to GatherFoldersAndFiles
             //GatherFoldersAndFiles();
         }
         else
         {
             foreach (var dep in AssetDatabase.GetDependencies(m_FullAssetName, true))
             {
                 if (dep != m_FullAssetName)
                 {
                     var asset = AssetBundleModel.CreateAsset(dep, this);
                     if (asset != null)
                     {
                         m_dependencies.Add(asset);
                     }
                 }
             }
         }
     }
     return(m_dependencies);
 }
예제 #2
0
        internal override void RefreshAssetList()
        {
            m_BundleMessages.SetFlag(MessageSystem.MessageFlag.AssetsDuplicatedInMultBundles, false);
            m_BundleMessages.SetFlag(MessageSystem.MessageFlag.SceneBundleConflict, false);
            m_BundleMessages.SetFlag(MessageSystem.MessageFlag.DependencySceneConflict, false);

            m_ConcreteAssets.Clear();
            m_TotalSize     = 0;
            m_IsSceneBundle = false;

            foreach (var asset in m_DependentAssets)
            {
                AssetBundleBrowser.Model.AssetBundleModel.UnRegisterAsset(asset, m_Name.fullNativeName);
            }
            m_DependentAssets.Clear();
            m_BundleDependencies.Clear();

            bool assetInBundle = false;
            bool sceneError    = false;
            var  assets        = AssetBundleBrowser.Model.AssetBundleModel.assetBundleData.GetAssetPathsFromAssetBundle(m_Name.fullNativeName);

            foreach (var assetName in assets)
            {
                if (AssetDatabase.GetMainAssetTypeAtPath(assetName) == typeof(SceneAsset))
                {
                    m_IsSceneBundle = true;
                    if (assetInBundle)
                    {
                        sceneError = true;
                    }
                }
                else
                {
                    assetInBundle = true;
                    if (m_IsSceneBundle)
                    {
                        sceneError = true;
                    }
                }

                var bundleName = AssetBundleModel.GetBundleName(assetName);
                if (System.String.IsNullOrEmpty(bundleName))
                {
                    ///we get here if the current asset is only added due to being in an explicitly added folder


                    var partialPath = assetName;
                    while (
                        !System.String.IsNullOrEmpty(partialPath) &&
                        partialPath != "Assets" &&
                        System.String.IsNullOrEmpty(bundleName))
                    {
                        partialPath = partialPath.Substring(0, partialPath.LastIndexOf('/'));
                        bundleName  = AssetBundleModel.GetBundleName(partialPath);
                    }
                    if (!System.String.IsNullOrEmpty(bundleName))
                    {
                        var folderAsset = AssetBundleModel.CreateAsset(partialPath, bundleName);
                        folderAsset.isFolder = true;
                        if (m_ConcreteAssets.FindIndex(a => a.displayName == folderAsset.displayName) == -1)
                        {
                            m_ConcreteAssets.Add(folderAsset);
                        }

                        var newAsset = AssetBundleModel.CreateAsset(assetName, folderAsset);
                        if (newAsset != null)
                        {
                            m_DependentAssets.Add(newAsset);
                            if (m_DependentAssets != null && m_DependentAssets.Count > 0)
                            {
                                var last = m_DependentAssets.Last();
                                if (last != null)
                                {
                                    m_TotalSize += last.fileSize;
                                }
                            }
                        }
                    }
                }
                else
                {
                    var newAsset = AssetBundleModel.CreateAsset(assetName, m_Name.fullNativeName);
                    if (newAsset != null)
                    {
                        m_ConcreteAssets.Add(newAsset);
                        m_TotalSize += m_ConcreteAssets.Last().fileSize;
                        if (AssetDatabase.GetMainAssetTypeAtPath(assetName) == typeof(SceneAsset))
                        {
                            m_IsSceneBundle = true;
                            m_ConcreteAssets.Last().isScene = true;
                        }
                    }
                }
            }

            if (sceneError)
            {
                foreach (var asset in m_ConcreteAssets)
                {
                    if (asset.isFolder)
                    {
                        asset.SetMessageFlag(MessageSystem.MessageFlag.DependencySceneConflict, true);
                        m_BundleMessages.SetFlag(MessageSystem.MessageFlag.DependencySceneConflict, true);
                    }
                    else
                    {
                        asset.SetMessageFlag(MessageSystem.MessageFlag.SceneBundleConflict, true);
                        m_BundleMessages.SetFlag(MessageSystem.MessageFlag.SceneBundleConflict, true);
                    }
                }
            }


            m_ConcreteCounter  = 0;
            m_DependentCounter = 0;
            m_Dirty            = true;
        }