internal virtual bool HandleChildRename(string oldName, string newName) { if (string.IsNullOrEmpty(oldName)) { AssetBundleModel.LogWarning("Attempting to Rename an item '" + "' which oldName is NullOrEmpty."); return(false); } if (string.IsNullOrEmpty(newName)) { AssetBundleModel.LogWarning("Attempting to Rename an item '" + "' which newName is NullOrEmpty."); return(false); } if (!System.String.IsNullOrEmpty(newName) && m_AssetBundleInfos.ContainsKey(newName)) { AssetBundleModel.LogWarning("Attempting to name an item '" + newName + "' which matches existing name at this level in hierarchy. If your desire is to merge bundles, drag one on top of the other."); return(false); } if (m_AssetBundleInfos.TryGetValue(oldName, out AssetBundleInfo info)) { m_AssetBundleInfos.Remove(oldName); m_AssetBundleInfos.Add(newName, info); } return(true); }
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); }
internal override void HandleReparent(string parentName, AssetBundleFolderInfo newParent = null) { RefreshAssetList(); string newName = System.String.IsNullOrEmpty(parentName) ? "" : parentName + '/'; newName += m_Name.shortName; if (newName == m_Name.bundleName) { return; } if (newParent != null && newParent.GetAssetBundleInfoByName(newName) != null) { AssetBundleModel.LogWarning("An item named '" + newName + "' already exists at this level in hierarchy. If your desire is to merge bundles, drag one on top of the other."); return; } foreach (var asset in m_ConcreteAssets) { AssetBundleModel.MoveAssetToBundle(asset, newName, m_Name.variant); } if (newParent != null) { m_Parent.HandleChildRename(m_Name.shortName, string.Empty); m_Parent = newParent; m_Parent.AddChild(this); } m_Name.SetBundleName(newName, m_Name.variant); }
internal override void HandleDelete(bool isRootOfDelete, string forcedNewName = "", string forcedNewVariant = "") { RefreshAssetList(); if (isRootOfDelete) { m_Parent.HandleChildRename(m_Name.variant, string.Empty); } AssetBundleModel.MoveAssetToBundle(m_ConcreteAssets, forcedNewName, forcedNewVariant); }
internal override bool HandleRename(string newName, int reverseDepth) { RefreshAssetList(); if (!base.HandleRename(newName, reverseDepth)) { return(false); } AssetBundleModel.MoveAssetToBundle(m_ConcreteAssets, m_Name.bundleName, m_Name.variant); return(true); }
private void GatherDependencies(AssetInfo asset, string parentBundle = "") { if (System.String.IsNullOrEmpty(parentBundle)) { parentBundle = asset.bundleName; } if (asset == null) { return; } var deps = asset.GetDependencies(); if (deps == null) { return; } foreach (var ai in deps) { if (ai == asset || m_ConcreteAssets.Contains(ai) || m_DependentAssets.Contains(ai)) { continue; } var bundleName = AssetBundleBrowser.Model.AssetBundleModel.assetBundleData.GetImplicitAssetBundleName(ai.fullAssetName); if (string.IsNullOrEmpty(bundleName)) { m_DependentAssets.Add(ai); m_TotalSize += ai.fileSize; if (AssetBundleModel.RegisterAsset(ai, parentBundle) > 1) { SetDuplicateWarning(); } } else if (bundleName != m_Name.fullNativeName) { BundleDependencyInfo dependencyInfo = m_BundleDependencies.Find(m => m.m_BundleName == bundleName); if (dependencyInfo == null) { dependencyInfo = new BundleDependencyInfo(bundleName, asset, ai); m_BundleDependencies.Add(dependencyInfo); } else { dependencyInfo.m_FromAssets.Add(asset); dependencyInfo.m_ToAssets.Add(ai); } } } }
internal override bool HandleRename(string newName, int reverseDepth) { if (reverseDepth == 0) { RefreshAssetList(); if (!m_Parent.HandleChildRename(m_Name.variant, newName)) { return(false); } m_Name.variant = newName; AssetBundleModel.MoveAssetToBundle(m_ConcreteAssets, m_Name.bundleName, m_Name.variant); } else if (reverseDepth == 1) { RefreshAssetList(); m_Name.PartialNameChange(newName + "." + m_Name.variant, 0); AssetBundleModel.MoveAssetToBundle(m_ConcreteAssets, m_Name.bundleName, m_Name.variant); } else { return(base.HandleRename(newName, reverseDepth - 1)); } return(true); }
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; }
internal override void HandleDelete(bool isRootOfDelete, string forcedNewName = "", string forcedNewVariant = "") { RefreshAssetList(); base.HandleDelete(isRootOfDelete); AssetBundleModel.MoveAssetToBundle(m_ConcreteAssets, forcedNewName, forcedNewVariant); }