/// <summary> /// The handle. /// </summary> /// <param name="asset"> /// The asset. /// </param> /// <param name="target"> /// The target. /// </param> /// <returns> /// The <see cref="dynamic"/>. /// </returns> public IRawAsset Handle(IAsset asset, AssetTarget target) { var configurationAsset = asset as ConfigurationAsset; var settings = configurationAsset.Settings; return new DictionaryBasedRawAsset(FlattenDictionary(settings)); }
/// <summary> /// 删除未使用的AB,可能是上次打包出来的,而这一次没生成的 /// </summary> /// <param name="all"></param> protected void RemoveUnused(List <AssetTarget> all) { HashSet <string> usedSet = new HashSet <string>(); for (int i = 0; i < all.Count; i++) { AssetTarget target = all[i]; if (target.needSelfExport) { usedSet.Add(target.bundleName); } } DirectoryInfo di = new DirectoryInfo(pathResolver.BundleSavePath); FileInfo[] abFiles = di.GetFiles("*.ab"); for (int i = 0; i < abFiles.Length; i++) { FileInfo fi = abFiles[i]; if (usedSet.Add(fi.Name)) { fi.Delete(); } } }
/// <summary> /// The handle. /// </summary> /// <param name="asset"> /// The asset. /// </param> /// <param name="target"> /// The target. /// </param> /// <returns> /// The <see cref="dynamic"/>. /// </returns> public IRawAsset Handle(IAsset asset, AssetTarget target) { var textAsset = asset as LanguageAsset; return new AnonymousObjectBasedRawAsset(new { Loader = typeof(LanguageAssetLoader).FullName, textAsset.Value }); }
/// <summary> /// The handle. /// </summary> /// <param name="asset"> /// The asset. /// </param> /// <param name="target"> /// The target. /// </param> /// <returns> /// The <see cref="dynamic"/>. /// </returns> public IRawAsset Handle(IAsset asset, AssetTarget target) { var textAsset = asset as LanguageAsset; return (new AnonymousObjectBasedRawAsset(new { Loader = typeof(LanguageAssetLoader).FullName, textAsset.Value })); }
/// <summary> /// The handle. /// </summary> /// <param name="asset"> /// The asset. /// </param> /// <param name="target"> /// The target. /// </param> /// <returns> /// The <see cref="dynamic"/>. /// </returns> public IRawAsset Handle(IAsset asset, AssetTarget target) { var configurationAsset = asset as ConfigurationAsset; var settings = configurationAsset.Settings; return(new DictionaryBasedRawAsset(FlattenDictionary(settings))); }
void BuildExportTree(AssetTarget parent, List <List <AssetTarget> > tree, int currentLevel) { if (parent.level == -1 && parent.type != AssetType.Builtin) { List <AssetTarget> levelList = null; if (tree.Count > currentLevel) { levelList = tree[currentLevel]; } else { levelList = new List <AssetTarget>(); tree.Add(levelList); } levelList.Add(parent); parent.UpdateLevel(currentLevel + 1, levelList); foreach (AssetTarget ei in parent.dependsChildren) { if (ei.level != -1 && ei.level <= parent.level) { ei.UpdateLevel(-1, null); } BuildExportTree(ei, tree, currentLevel + 1); } } }
void BuildExportTree(AssetTarget parent, List<List<AssetTarget>> tree, int currentLevel) { if (parent.level == -1 && parent.type != AssetType.Builtin) { List<AssetTarget> levelList = null; if (tree.Count > currentLevel) { levelList = tree[currentLevel]; } else { levelList = new List<AssetTarget>(); tree.Add(levelList); } levelList.Add(parent); parent.UpdateLevel(currentLevel + 1, levelList); foreach (AssetTarget ei in parent.dependsChildren) { if (ei.level != -1 && ei.level <= parent.level) { ei.UpdateLevel(-1, null); } BuildExportTree(ei, tree, currentLevel + 1); } } }
/// <summary> /// The handle. /// </summary> /// <param name="asset"> /// The asset. /// </param> /// <param name="target"> /// The target. /// </param> /// <returns> /// The <see cref="dynamic"/>. /// </returns> public IRawAsset Handle(IAsset asset, AssetTarget target) { var textureAsset = asset as TextureAsset; if (textureAsset.SourcedFromRaw && target != AssetTarget.CompiledFile) { // We were sourced from a raw PNG; we don't want to save // an ".asset" file back to disk. return null; } if (target == AssetTarget.CompiledFile) { return new CompiledAsset { Loader = typeof(TextureAssetLoader).FullName, PlatformData = textureAsset.PlatformData }; } return new AnonymousObjectBasedRawAsset( new { Loader = typeof(TextureAssetLoader).FullName, PlatformData = target == AssetTarget.SourceFile ? null : textureAsset.PlatformData, RawData = textureAsset.RawData == null ? null : textureAsset.RawData.Select(x => (int)x).ToList() }); }
public void AddRootTargets(DirectoryInfo bundleDir, EnAssetBundleFilter type, string[] partterns = null, SearchOption searchOption = SearchOption.AllDirectories) { if (partterns == null) { partterns = new string[] { "*.*" } } ; for (int i = 0; i < partterns.Length; i++) { FileInfo[] prefabs = bundleDir.GetFiles(partterns[i], searchOption); foreach (FileInfo file in prefabs) { AssetTarget target = ABBuilderTools.Load(file, null); target.filterType = type; if (type == EnAssetBundleFilter.合并) { target.exportType = EnAssetBundleExportType.RootMerge; int index = bundleDir.FullName.IndexOf("Assets"); target.SetAbName(bundleDir.FullName.Substring(index).Replace("\\", "/") + "/" + bundleDir.Name + ABBuilderTools.AbExtension); } else { target.exportType = EnAssetBundleExportType.Root; } config.Add(target); } } }
/// <summary> /// The handle. /// </summary> /// <param name="asset"> /// The asset. /// </param> /// <param name="target"> /// The target. /// </param> /// <returns> /// The <see cref="dynamic"/>. /// </returns> public IRawAsset Handle(IAsset asset, AssetTarget target) { var modelAsset = asset as ModelAsset; if (modelAsset.SourcedFromRaw && target != AssetTarget.CompiledFile) { // We were sourced from a raw FBX; we don't want to save // an ".asset" file back to disk. return(null); } if (target == AssetTarget.CompiledFile) { return(new CompiledAsset { Loader = typeof(ModelAssetLoader).FullName, PlatformData = modelAsset.PlatformData }); } return (new AnonymousObjectBasedRawAsset( new { Loader = typeof(ModelAssetLoader).FullName, PlatformData = target == AssetTarget.SourceFile ? null : modelAsset.PlatformData, RawData = modelAsset.RawData == null ? null : modelAsset.RawData.Select(x => (int)x).ToList(), RawAdditionalAnimations = (Dictionary <string, byte[]>)null })); }
/// <summary> /// The handle. /// </summary> /// <param name="asset"> /// The asset. /// </param> /// <param name="target"> /// The target. /// </param> /// <returns> /// The <see cref="dynamic"/>. /// </returns> public IRawAsset Handle(IAsset asset, AssetTarget target) { var fontAsset = asset as FontAsset; if (target == AssetTarget.CompiledFile) { if (fontAsset.PlatformData == null) { throw new InvalidOperationException( "Attempted save of font asset as a compiled file, but the font wasn't compiled. This usually " + "indicates that the font '" + fontAsset.FontName + "' is not installed on the current system."); } return(new CompiledAsset { Loader = typeof(FontAssetLoader).FullName, PlatformData = fontAsset.PlatformData }); } return (new AnonymousObjectBasedRawAsset( new { Loader = typeof(FontAssetLoader).FullName, fontAsset.FontSize, fontAsset.FontName, fontAsset.UseKerning, fontAsset.Spacing, PlatformData = target == AssetTarget.SourceFile ? null : fontAsset.PlatformData })); }
/// <summary> /// The handle. /// </summary> /// <param name="asset"> /// The asset. /// </param> /// <param name="target"> /// The target. /// </param> /// <returns> /// The <see cref="dynamic"/>. /// </returns> public IRawAsset Handle(IAsset asset, AssetTarget target) { var fontAsset = asset as FontAsset; if (target == AssetTarget.CompiledFile) { if (fontAsset.PlatformData == null) { throw new InvalidOperationException( "Attempted save of font asset as a compiled file, but the font wasn't compiled. This usually " + "indicates that the font '" + fontAsset.FontName + "' is not installed on the current system."); } return new CompiledAsset { Loader = typeof(FontAssetLoader).FullName, PlatformData = fontAsset.PlatformData }; } return new AnonymousObjectBasedRawAsset( new { Loader = typeof(FontAssetLoader).FullName, fontAsset.FontSize, fontAsset.FontName, fontAsset.UseKerning, fontAsset.Spacing, PlatformData = target == AssetTarget.SourceFile ? null : fontAsset.PlatformData }); }
public virtual void Save(Stream stream, AssetTarget[] targets) { StreamWriter sw = new StreamWriter(stream); //写入文件头判断文件类型用,ABDT 意思即 Asset-Bundle-Data-Text sw.WriteLine("ABDT"); for (int i = 0; i < targets.Length; i++) { AssetTarget target = targets[i]; HashSet <AssetTarget> deps = new HashSet <AssetTarget>(); target.GetDependencies(deps); //bundle name sw.WriteLine(target.bundleName); //File Name sw.WriteLine(target.file.Name); //hash sw.WriteLine(target.bundleCrc); //type sw.WriteLine((int)target.compositeType); //写入依赖信息 sw.WriteLine(deps.Count); foreach (AssetTarget item in deps) { sw.WriteLine(item.bundleName); } } sw.Close(); }
public virtual void Save(Stream stream, AssetTarget[] targets) { StreamWriter sw = new StreamWriter(stream); //写入文件头判断文件类型用,ABDT 意思即 Asset-Bundle-Data-Text sw.WriteLine("ABDT"); for (int i = 0; i < targets.Length; i++) { AssetTarget target = targets[i]; HashSet<AssetTarget> deps = new HashSet<AssetTarget>(); target.GetDependencies(deps); //debug name sw.WriteLine(target.assetPath); //bundle name sw.WriteLine(target.bundleName); //File Name sw.WriteLine(target.bundleShortName); //hash sw.WriteLine(target.bundleCrc); //type sw.WriteLine((int)target.compositeType); //写入依赖信息 sw.WriteLine(deps.Count); foreach (AssetTarget item in deps) { sw.WriteLine(item.bundleName); } sw.WriteLine("<------------->"); } sw.Close(); }
/// <summary> /// The handle. /// </summary> /// <param name="asset"> /// The asset. /// </param> /// <param name="target"> /// The target. /// </param> /// <returns> /// The <see cref="dynamic"/>. /// </returns> public IRawAsset Handle(IAsset asset, AssetTarget target) { var textureAsset = asset as TextureAsset; if (textureAsset.SourcedFromRaw && target != AssetTarget.CompiledFile) { // We were sourced from a raw PNG; we don't want to save // an ".asset" file back to disk. return(null); } if (target == AssetTarget.CompiledFile) { return(new CompiledAsset { Loader = typeof(TextureAssetLoader).FullName, PlatformData = textureAsset.PlatformData }); } return (new AnonymousObjectBasedRawAsset( new { Loader = typeof(TextureAssetLoader).FullName, PlatformData = target == AssetTarget.SourceFile ? null : textureAsset.PlatformData, RawData = textureAsset.RawData == null ? null : textureAsset.RawData.Select(x => (int)x).ToList() })); }
public void Parse() { for (int i = 0; i < filters.Count; i++) { AssetTarget target = filters[i]; maps[target.assetPath] = target; } }
/// <summary> /// The handle. /// </summary> /// <param name="asset"> /// The asset. /// </param> /// <param name="target"> /// The target. /// </param> /// <returns> /// The <see cref="dynamic"/>. /// </returns> public IRawAsset Handle(IAsset asset, AssetTarget target) { var levelAsset = asset as LevelAsset; return new AnonymousObjectBasedRawAsset( new { Loader = typeof(LevelAssetLoader).FullName, levelAsset.Value, levelAsset.SourcePath }); }
/// <summary> /// The handle. /// </summary> /// <param name="asset"> /// The asset. /// </param> /// <param name="target"> /// The target. /// </param> /// <returns> /// The <see cref="dynamic"/>. /// </returns> public IRawAsset Handle(IAsset asset, AssetTarget target) { var levelAsset = asset as LevelAsset; return (new AnonymousObjectBasedRawAsset( new { Loader = typeof(LevelAssetLoader).FullName, levelAsset.Value, levelAsset.SourcePath })); }
public IRawAsset Handle(IAsset asset, AssetTarget target) { var variableAsset = asset as VariableAsset; return new AnonymousObjectBasedRawAsset( new { Loader = typeof(VariableAssetLoader).FullName, Value = variableAsset.RawValue }); }
public IRawAsset Handle(IAsset asset, AssetTarget target) { var variableAsset = asset as VariableAsset; return (new AnonymousObjectBasedRawAsset( new { Loader = typeof(VariableAssetLoader).FullName, Value = variableAsset.RawValue })); }
/// <summary> /// Handles saving the LogicControl script. /// </summary> /// <param name="asset">The script asset to save.</param> /// <param name="target">The saved asset target.</param> /// <returns>The raw asset data to be saved by <see cref="IRawAssetSaver"/>.</returns> public IRawAsset Handle(IAsset asset, AssetTarget target) { var scriptAsset = asset as ScriptAsset; return new AnonymousObjectBasedRawAsset( new { Loader = typeof(LogicControlScriptAssetLoader).FullName, Code = scriptAsset.Code.Replace("\r\n", "\n") }); }
/// <summary> /// Handles saving the LogicControl script. /// </summary> /// <param name="asset">The script asset to save.</param> /// <param name="target">The saved asset target.</param> /// <returns>The raw asset data to be saved by <see cref="IRawAssetSaver"/>.</returns> public IRawAsset Handle(IAsset asset, AssetTarget target) { var scriptAsset = asset as ScriptAsset; return (new AnonymousObjectBasedRawAsset( new { Loader = typeof(LogicControlScriptAssetLoader).FullName, Code = scriptAsset.Code.Replace("\r\n", "\n") })); }
public void Add(AssetTarget target) { if (maps.ContainsKey(target.assetPath)) { return; } filters.Add(target); maps[target.assetPath] = target; }
public void Remove(AssetTarget target) { if (!maps.ContainsKey(target.assetPath)) { return; } filters.Remove(target); maps.Remove(target.assetPath); }
public dynamic Handle(IAsset asset, AssetTarget target) { var elementDefinitionAsset = (ElementDefinitionAsset)asset; return new { Loader = typeof(ElementDefinitionAssetLoader).FullName, DisplayName = elementDefinitionAsset.DisplayName != null ? elementDefinitionAsset.DisplayName.Name : null }; }
void Export(AssetTarget target) { if (target.needExport) { //写入 .assetbundle 包 target.WriteBundle(options); if (target.isNewBuild) { newBuildTargets.Add(target); } } }
public dynamic Handle(IAsset asset, AssetTarget target) { var abilityTypeDefinitionAsset = (AbilityTypeDefinitionAsset)asset; return new { Loader = typeof(AbilityTypeDefinitionAssetLoader).FullName, DisplayName = abilityTypeDefinitionAsset.DisplayName != null ? abilityTypeDefinitionAsset.DisplayName.Name : null, Description = abilityTypeDefinitionAsset.Description != null ? abilityTypeDefinitionAsset.Description.Name : null, AI = abilityTypeDefinitionAsset.AI != null ? abilityTypeDefinitionAsset.AI.Name : null, Category = abilityTypeDefinitionAsset.Category != null ? abilityTypeDefinitionAsset.Category : null }; }
/// <summary> /// The handle. /// </summary> /// <param name="asset"> /// The asset. /// </param> /// <param name="target"> /// The target. /// </param> /// <returns> /// The <see cref="dynamic"/>. /// </returns> public IRawAsset Handle(IAsset asset, AssetTarget target) { var tilesetAsset = asset as TilesetAsset; return (new AnonymousObjectBasedRawAsset( new { Loader = typeof(TilesetAssetLoader).FullName, TextureName = tilesetAsset.Texture != null ? tilesetAsset.Texture.Name : null, tilesetAsset.CellWidth, tilesetAsset.CellHeight })); }
public override void Export() { base.Export(); //标记所有 asset bundle name var all = AssetBundleUtils.GetAll(); for (int i = 0; i < all.Count; i++) { AssetTarget target = all[i]; AssetImporter importer = AssetImporter.GetAtPath(target.assetPath); if (importer) { if (target.needSelfExport) { importer.assetBundleName = target.bundleName; } else { importer.assetBundleName = null; } } } //开始打包 BuildPipeline.BuildAssetBundles(this.pathResolver.BundleSavePath, BuildAssetBundleOptions.UncompressedAssetBundle, EditorUserBuildSettings.activeBuildTarget); #if UNITY_5_3 || UNITY_5_4 AssetBundle ab = AssetBundle.LoadFromFile(pathResolver.BundleSavePath + "/AssetBundles"); #else AssetBundle ab = AssetBundle.CreateFromFile(pathResolver.BundleSavePath + "/AssetBundles"); #endif AssetBundleManifest manifest = ab.LoadAsset("AssetBundleManifest") as AssetBundleManifest; //清除所有 asset bundle name for (int i = 0; i < all.Count; i++) { AssetTarget target = all[i]; Hash128 hash = manifest.GetAssetBundleHash(target.bundleName); target.bundleCrc = hash.ToString(); AssetImporter importer = AssetImporter.GetAtPath(target.assetPath); if (importer) { importer.assetBundleName = null; } } this.SaveDepAll(all); ab.Unload(true); //this.RemoveUnused(all); }
public IRawAsset Handle(IAsset asset, AssetTarget target) { var userInterfaceAsset = asset as UserInterfaceAsset; return (new AnonymousObjectBasedRawAsset( new { Loader = typeof(UserInterfaceAssetLoader).FullName, userInterfaceAsset.UserInterfaceData, userInterfaceAsset.UserInterfaceFormat, userInterfaceAsset.SourcePath })); }
public IRawAsset Handle(IAsset asset, AssetTarget target) { var userInterfaceAsset = asset as UserInterfaceAsset; return new AnonymousObjectBasedRawAsset( new { Loader = typeof(UserInterfaceAssetLoader).FullName, userInterfaceAsset.UserInterfaceData, userInterfaceAsset.UserInterfaceFormat, userInterfaceAsset.SourcePath }); }
/// <summary> /// The handle. /// </summary> /// <param name="asset"> /// The asset. /// </param> /// <param name="target"> /// The target. /// </param> /// <returns> /// The <see cref="dynamic"/>. /// </returns> public IRawAsset Handle(IAsset asset, AssetTarget target) { var tilesetAsset = asset as TilesetAsset; return new AnonymousObjectBasedRawAsset( new { Loader = typeof(TilesetAssetLoader).FullName, TextureName = tilesetAsset.Texture != null ? tilesetAsset.Texture.Name : null, tilesetAsset.CellWidth, tilesetAsset.CellHeight }); }
public dynamic Handle(IAsset asset, AssetTarget target) { var spellDefinitionAsset = (SpellDefinitionAsset)asset; return new { Loader = typeof(SpellDefinitionAssetLoader).FullName, Description = spellDefinitionAsset.Description, Target = spellDefinitionAsset.Target, Type = spellDefinitionAsset.Type, Range = spellDefinitionAsset.Range, Effect = spellDefinitionAsset.Effect, EffectPerLevel = spellDefinitionAsset.EffectPerLevel }; }
public static AssetTarget Load(FileInfo file, System.Type t) { AssetTarget target = null; string fullPath = file.FullName; int index = fullPath.IndexOf("Assets"); if (index == -1) { return(target); } string assetPath = fullPath.Substring(index); target = new AssetTarget(file, assetPath); return(target); }
public dynamic Handle(IAsset asset, AssetTarget target) { var beingDefinitionAsset = (BeingDefinitionAsset)asset; return new { Loader = typeof(BeingDefinitionAssetLoader).FullName, DisplayName = beingDefinitionAsset.DisplayName != null ? beingDefinitionAsset.DisplayName.Name : null, Description = beingDefinitionAsset.Description != null ? beingDefinitionAsset.Description.Name : null, TextureName = beingDefinitionAsset.Texture != null ? beingDefinitionAsset.Texture.Name : null, HealthPerLevel = beingDefinitionAsset.HealthPerLevel, MovementSpeed = beingDefinitionAsset.MovementSpeed, Enemy = beingDefinitionAsset.Enemy }; }
public override void Save(Stream stream, AssetTarget[] targets) { BinaryWriter sw = new BinaryWriter(stream); //写入文件头判断文件类型用,ABDB 意思即 Asset-Bundle-Data-Binary sw.Write(new char[] { 'A', 'B', 'D', 'B' }); List<string> bundleNames = new List<string>(); for (int i = 0; i < targets.Length; i++) { AssetTarget target = targets[i]; bundleNames.Add(target.bundleName); } //写入文件名池 sw.Write(bundleNames.Count); for (int i = 0; i < bundleNames.Count; i++) { sw.Write(bundleNames[i]); } //写入详细信息 for (int i = 0; i < targets.Length; i++) { AssetTarget target = targets[i]; HashSet<AssetTarget> deps = new HashSet<AssetTarget>(); target.GetDependencies(deps); //debug name sw.Write(target.assetPath); //bundle name sw.Write(bundleNames.IndexOf(target.bundleName)); //File Name sw.Write(target.bundleShortName); //hash sw.Write(target.bundleCrc); //type sw.Write((int)target.compositeType); //写入依赖信息 sw.Write(deps.Count); foreach (AssetTarget item in deps) { sw.Write(bundleNames.IndexOf(item.bundleName)); } } sw.Close(); }
public dynamic Handle(IAsset asset, AssetTarget target) { var blockAsset = (BlockAsset)asset; return new { Loader = typeof(BlockAssetLoader).FullName, blockAsset.BlockID, TopTextureName = blockAsset.TopTexture != null ? blockAsset.TopTexture.Name : null, BottomTextureName = blockAsset.BottomTexture != null ? blockAsset.BottomTexture.Name : null, LeftTextureName = blockAsset.LeftTexture != null ? blockAsset.LeftTexture.Name : null, RightTextureName = blockAsset.RightTexture != null ? blockAsset.RightTexture.Name : null, FrontTextureName = blockAsset.FrontTexture != null ? blockAsset.FrontTexture.Name : null, BackTextureName = blockAsset.BackTexture != null ? blockAsset.BackTexture.Name : null, blockAsset.Impassable }; }
public override void Save(Stream stream, AssetTarget[] targets) { BinaryWriter sw = new BinaryWriter(stream); //写入文件头判断文件类型用,ABDB 意思即 Asset-Bundle-Data-Binary sw.Write(new char[] { 'A', 'B', 'D', 'B' }); List <string> bundleNames = new List <string>(); for (int i = 0; i < targets.Length; i++) { AssetTarget target = targets[i]; bundleNames.Add(target.bundleName); } //写入文件名池 sw.Write(bundleNames.Count); for (int i = 0; i < bundleNames.Count; i++) { sw.Write(bundleNames[i]); } //写入详细信息 for (int i = 0; i < targets.Length; i++) { AssetTarget target = targets[i]; HashSet <AssetTarget> deps = new HashSet <AssetTarget>(); target.GetDependencies(deps); //bundle name sw.Write(bundleNames.IndexOf(target.bundleName)); //File Name sw.Write(target.file.Name); //hash sw.Write(target.bundleCrc); //type sw.Write((int)target.compositeType); //写入依赖信息 sw.Write(deps.Count); foreach (AssetTarget item in deps) { sw.Write(bundleNames.IndexOf(item.bundleName)); } } sw.Close(); }
void OnGUI() { if (mConfig == null) { InitConfig(); } if (mList == null) { InitFilterListDrawer(); } GUILayout.Space(10); string before = s_search_text; string after = EditorGUILayout.TextField("", before, "SearchTextField", GUILayout.Width(200)); if (before != after) { s_search_text = after.Trim(); if (!string.IsNullOrEmpty(s_search_text)) { filterList.Clear(); for (int i = 0; i < mConfig.filters.Count; i++) { AssetTarget target = mConfig.filters[i]; if (target.shortPath.IndexOf(s_search_text) >= 0) { filterList.Add(target); } } mList = null; return; } } //context GUILayout.BeginVertical(); { GUILayout.Space(10); mScrollPosition = GUILayout.BeginScrollView(mScrollPosition); { mList.DoLayoutList(); } GUILayout.EndScrollView(); } GUILayout.EndVertical(); }
public void AddRootTargets(DirectoryInfo bundleDir, string[] partterns = null, SearchOption searchOption = SearchOption.AllDirectories) { if (partterns == null) { partterns = new string[] { "*.*" } } ; for (int i = 0; i < partterns.Length; i++) { FileInfo[] prefabs = bundleDir.GetFiles(partterns[i], searchOption); foreach (FileInfo file in prefabs) { AssetTarget target = AssetBundleUtils.Load(file); target.exportType = AssetBundleExportType.Root; } } }
public void ClearMark() { for (int i = 0; i < filters.Count; i++) { AssetTarget target = filters[i]; //root不清理 if (target.exportType == EnAssetBundleExportType.Root) { continue; } if (target.exportType == EnAssetBundleExportType.RootMerge) { continue; } target.exportType = EnAssetBundleExportType.None; target.abPath = null; } }
void OnListElementGUI(Rect rect, int index, bool isactive, bool isfocused) { AssetTarget filter = filterList[index]; rect.y++; Rect r = rect; r.width = 300; GUI.Label(r, filter.shortPath); r.x += r.width + 10; r.width = 400; GUI.Label(r, filter.abPath); r.x += r.width + 10; r.width = 80; GUI.Label(r, filter.exportType.ToString()); }
public IRawAsset Handle(IAsset asset, AssetTarget target) { var textureAtlasAsset = (TextureAtlasAsset)asset; if (target == AssetTarget.CompiledFile) { return new CompiledAsset { Loader = typeof(TextureAtlasAssetLoader).FullName, PlatformData = new PlatformData { Platform = textureAtlasAsset.AtlasTexture.PlatformData.Platform, Data = textureAtlasAsset.GetCompiledData() } }; } // TODO: Are there any scenarios where we want to save the .asset file? return null; }
public IRawAsset Handle(IAsset asset, AssetTarget target) { var textureAtlasAsset = (TextureAtlasAsset)asset; if (target == AssetTarget.CompiledFile) { return(new CompiledAsset { Loader = typeof(TextureAtlasAssetLoader).FullName, PlatformData = new PlatformData { Platform = textureAtlasAsset.AtlasTexture.PlatformData.Platform, Data = textureAtlasAsset.GetCompiledData() } }); } // TODO: Are there any scenarios where we want to save the .asset file? return(null); }
public dynamic Handle(IAsset asset, AssetTarget target) { var beingClusterDefinitionAsset = (BeingClusterDefinitionAsset)asset; string[] beingDefinitions = null; if (beingClusterDefinitionAsset.BeingDefinitions != null) { beingDefinitions = beingClusterDefinitionAsset.BeingDefinitions.Select(x => x == null ? null : x.Name).ToArray(); } return new { Loader = typeof(BeingClusterDefinitionAssetLoader).FullName, Keyword = beingClusterDefinitionAsset.Keyword, LevelRequirement = beingClusterDefinitionAsset.LevelRequirement, Enemy = beingClusterDefinitionAsset.Enemy, BeingDefinitions = beingDefinitions, Minimum = beingClusterDefinitionAsset.Minimum, Maximum = beingClusterDefinitionAsset.Maximum }; }
public void SaveBundle() { ByteArray bytes = new ByteArray(); int count = 0; for (int i = 0; i < filters.Count; i++) { if (filters[i].exportType == EnAssetBundleExportType.Asset) { continue; } count++; } bytes.WriteInt(count); for (int i = 0; i < filters.Count; i++) { AssetTarget target = filters[i]; if (target.exportType == EnAssetBundleExportType.Asset) { continue; } bytes.WriteUTF(target.shortPath); bytes.WriteUTF(target.assetPath); bytes.WriteUTF(target.abPath); bytes.WriteByte((byte)target.exportType); } try { byte[] byteArray = bytes.Buffer; FileStream fs = new FileStream(ABBuilderTools.AbDataPath, FileMode.Create); fs.Write(byteArray, 0, byteArray.Length); fs.Close(); fs.Dispose(); } catch (Exception e) { Loger.Error(e.ToString()); } }
protected void SaveDepAll(List <AssetTarget> all) { string path = Path.Combine(pathResolver.BundleSavePath, pathResolver.DependFileName); if (File.Exists(path)) { File.Delete(path); } List <AssetTarget> exportList = new List <AssetTarget>(); for (int i = 0; i < all.Count; i++) { AssetTarget target = all[i]; if (target.needSelfExport) { exportList.Add(target); } } AssetBundleDataWriter writer = dataWriter; writer.Save(path, exportList.ToArray()); }
/// <summary> /// The handle. /// </summary> /// <param name="asset"> /// The asset. /// </param> /// <param name="target"> /// The target. /// </param> /// <returns> /// The <see cref="dynamic"/>. /// </returns> public IRawAsset Handle(IAsset asset, AssetTarget target) { var effectAsset = asset as EffectAsset; if (effectAsset.SourcedFromRaw && target != AssetTarget.CompiledFile) { // We were sourced from a raw FX; we don't want to save // an ".asset" file back to disk. return null; } if (target == AssetTarget.CompiledFile) { if (effectAsset.PlatformData == null) { throw new InvalidOperationException( "Attempted save of effect asset as a compiled file, but the effect wasn't compiled. This usually " + "indicates that you are compiling on Linux, but no remote effect compiler on a Windows machine " + "could be located to perform the compilation."); } return new CompiledAsset { Loader = typeof(EffectAssetLoader).FullName, PlatformData = effectAsset.PlatformData }; } return new AnonymousObjectBasedRawAsset( new { Loader = typeof(EffectAssetLoader).FullName, effectAsset.Code, PlatformData = target == AssetTarget.SourceFile ? null : effectAsset.PlatformData }); }
/// <summary> /// The handle. /// </summary> /// <param name="asset"> /// The asset. /// </param> /// <param name="target"> /// The target. /// </param> /// <returns> /// The <see cref="dynamic"/>. /// </returns> public IRawAsset Handle(IAsset asset, AssetTarget target) { var effectAsset = asset as EffectAsset; if (effectAsset.SourcedFromRaw && target != AssetTarget.CompiledFile) { // We were sourced from a raw FX; we don't want to save // an ".asset" file back to disk. return(null); } if (target == AssetTarget.CompiledFile) { if (effectAsset.PlatformData == null) { throw new InvalidOperationException( "Attempted save of effect asset as a compiled file, but the effect wasn't compiled. This usually " + "indicates that you are compiling on Linux, but no remote effect compiler on a Windows machine " + "could be located to perform the compilation."); } return(new CompiledAsset { Loader = typeof(EffectAssetLoader).FullName, PlatformData = effectAsset.PlatformData }); } return (new AnonymousObjectBasedRawAsset( new { Loader = typeof(EffectAssetLoader).FullName, effectAsset.Code, PlatformData = target == AssetTarget.SourceFile ? null : effectAsset.PlatformData })); }
public void SetChildDependenciesAssetBundle(AssetTarget target) { target.SetAbName(GetAbName(target.assetPath, true)); string[] dependenciesList = AssetDatabase.GetDependencies(target.assetPath); for (int k = 0; k < dependenciesList.Length; k++) { string dependenciesUrl = dependenciesList[k]; if (dependenciesUrl == target.assetPath || dependenciesUrl.EndsWith(".cs") || dependenciesUrl.EndsWith(".asset")) { continue; } AssetTarget dependenciesTarget = Get(dependenciesUrl); if (dependenciesTarget == null) { dependenciesTarget = ABBuilderTools.Load(new FileInfo(dependenciesUrl), null); Add(dependenciesTarget); } switch (dependenciesTarget.exportType) { case EnAssetBundleExportType.None: dependenciesTarget.exportType = EnAssetBundleExportType.Asset; dependenciesTarget.SetAbName(GetAbName(target.assetPath, false)); dependenciesTarget.AddParent(target.abPath); break; case EnAssetBundleExportType.Asset: dependenciesTarget.AddParent(target.abPath); if (dependenciesTarget.ParentList.Count > 1) { dependenciesTarget.SetAbName(GetAbName(dependenciesUrl, false)); dependenciesTarget.exportType = EnAssetBundleExportType.Standalone; } break; } } }
public void Save(string path, AssetTarget[] targets) { FileStream fs = new FileStream(path, FileMode.CreateNew); Save(fs, targets); }
void Export(AssetTarget target) { if (target.needExport) { //写入 .assetbundle 包 target.BuildBundle(options); if (target.isNewBuild) newBuildTargets.Add(target); } }
public static AssetTarget Load(FileInfo file, System.Type t) { AssetTarget target = null; string fullPath = file.FullName; int index = fullPath.IndexOf("Assets"); if (index != -1) { string assetPath = fullPath.Substring(index); if (_assetPath2target.ContainsKey(assetPath)) { target = _assetPath2target[assetPath]; } else { Object o = null; if (t == null) o = AssetDatabase.LoadMainAssetAtPath(assetPath); else o = AssetDatabase.LoadAssetAtPath(assetPath, t); if (o != null) { int instanceId = o.GetInstanceID(); if (_object2target.ContainsKey(instanceId)) { target = _object2target[instanceId]; } else { target = new AssetTarget(o, file, assetPath); string key = string.Format("{0}/{1}", assetPath, instanceId); _assetPath2target[key] = target; _object2target[instanceId] = target; } } } } return target; }
public static AssetTarget Load(Object o) { AssetTarget target = null; if (o != null) { int instanceId = o.GetInstanceID(); if (_object2target.ContainsKey(instanceId)) { target = _object2target[instanceId]; } else { string assetPath = AssetDatabase.GetAssetPath(o); string key = assetPath; //Builtin,内置素材,path为空 if (string.IsNullOrEmpty(assetPath)) key = string.Format("Builtin______{0}", o.name); else key = string.Format("{0}/{1}", assetPath, instanceId); if (_assetPath2target.ContainsKey(key)) { target = _assetPath2target[key]; } else { if (assetPath.StartsWith("Resources")) { assetPath = string.Format("{0}/{1}.{2}", assetPath, o.name, o.GetType().Name); } FileInfo file = new FileInfo(Path.Combine(ProjectPath, assetPath)); target = new AssetTarget(o, file, assetPath); _object2target[instanceId] = target; _assetPath2target[key] = target; } } } return target; }
public dynamic Handle(IAsset asset, AssetTarget target) { return null; }