public ITopologyConfig SetMashup(string[] previous, Func <IInputs, object> mashupFunction) { if (mashupItem != null) { throw new ArgumentException("已设定Mashup,不能重复设置"); } mashupItem = new DependItem() { Name = LastName, Previous = previous, Type = typeof(MashupDelegate), MashupFunction = mashupFunction }; return(this); }
private void SetDependOn(DependItem bolt) { if (bolt.Previous == null || bolt.Previous.Length < 1) { return; } DependItem dependBolt; foreach (var previou in bolt.Previous) { if (boltDependlist.TryGetValue(previou, out dependBolt)) { bolt.AddDependOn(dependBolt); } } }
public ITopologyConfig SetMashup(string[] previous, Type mashupType) { if (mashupType == null) { throw new ArgumentException("参数2错误,不能为null且应为IMashup类型"); } if (mashupType.GetInterface(typeof(IMashup).Name, true) == null) { throw new ArgumentException("参数2类型错误,应为IMashup类型"); } if (mashupItem != null) { throw new ArgumentException("已设定Mashup,不能重复设置"); } mashupItem = new DependItem() { Name = LastName, Previous = previous, Type = mashupType }; return(this); }
/// <summary> /// UI预制体按文件夹制作成一个大的assetbundle /// </summary> /// <param name="rootDirectoryPath"></param> /// <param name="fileSuffixString"></param> private static void GUIAssetBundleDep(string rootDirectoryPath, string fileSuffixString, string assetBundleName) { var pathList = GetFilesPath(rootDirectoryPath, fileSuffixString); List <Object> objList = new List <Object>(); string dependentBundleNames = "Assets/DependentBundleNames.asset"; StringHolder holder = ScriptableObject.CreateInstance <StringHolder>(); holder.dependencies = new List <DependItem>(); for (int index = 0; index < pathList.Count; index++) { string file_path = pathList[index]; Object obj = GetObject(file_path); if (obj == null) { continue; } file_path = AssetDatabase.GetAssetPath(obj); List <string> depBundleNames = new List <string>(); string[] depAssetPaths = AssetDatabase.GetDependencies(new string[] { file_path }); Log("********Start**********" + file_path); for (int i = 0; i < depAssetPaths.Length; i++) { string depAssetPath = depAssetPaths[i]; //自己不用添加对自己的依赖关系 if (depAssetPath == file_path) { continue; } //所有的GUI prefab已经被打在了一个AssetBundle中,无需要依赖关系 if (depAssetPath.StartsWith("Assets/Resources/Prefab/GUI/")) { continue; } Object depAsset = AssetDatabase.LoadAssetAtPath(depAssetPath, typeof(UnityEngine.Object)); string depBundlePath = ""; /* **************************************** * 当前UI预制体会和一下类型存在依赖关系 * 1、系统字体 * 2、声音 * 3、UI字体(图片字体) * 4、UI图集 * 备注:UI使用到的动画都在一个assetbundle里面,这里就不添加关联关系了。 * ****************************************/ if (depAsset is Font || depAsset is AudioClip || depAssetPath.ToLower().Contains("texture/")) { depBundlePath = GetAssetBundleByResPath(depAssetPath); } else if (depAsset is GameObject) { GameObject depObject = depAsset as GameObject; if (depObject.GetComponents <UIFont>() != null || depObject.GetComponents <UIAtlas>() != null) { depBundlePath = GetAssetBundleByResPath(depAssetPath); } } if (!string.IsNullOrEmpty(depBundlePath)) { depBundleNames.Add(depBundlePath); Log("dep add " + depBundlePath); } } Log("********End**********" + file_path); //添加依赖描述信息 DependItem item = new DependItem(); item.name = obj.name; item.list = depBundleNames; holder.dependencies.Add(item); //当前的游戏对象添加到队列中 objList.Add(obj); } AssetDatabase.CreateAsset(holder, dependentBundleNames); Object depBundleDescription = AssetDatabase.LoadAssetAtPath(dependentBundleNames, typeof(StringHolder)); //assetBundlePath路径 string assetBundlePath = rootDirectoryPath + "/" + assetBundleName + ".assetbundle"; assetBundlePath = assetBundlePath.Substring(Application.dataPath.Length - 6); assetBundlePath = GetAssetBundlePath(assetBundlePath); BuildPipeline.BuildAssetBundle(depBundleDescription, objList.ToArray(), assetBundlePath, buildOp, buildTarget); //填充资源列表,在添加依赖关系时会使用 foreach (var obj in objList) { string assetPath = AssetDatabase.GetAssetPath(obj); AddResouce(assetBundlePath, assetPath); } AssetDatabase.DeleteAsset(dependentBundleNames); AssetDatabase.Refresh(); }