private object menuCommand; //ICommand or IViewProvider public ToolBarCommand(XmlNode node, IBundle owner, bool createCommand) { RightToLeft = RightToLeft.Inherit; this.node = node; this.owner = owner; if (createCommand) { LoadClass(); } if (Image == null) { string icon = XmlUtility.ReadAttribute(node, "icon"); if (!string.IsNullOrEmpty(icon)) { Image = ResourcesUtility.TryGetBitmap(owner.LoadResource(icon, ResourceLoadMode.ClassSpace)); } } Text = XmlUtility.ReadAttribute(node, "text"); ToolTipText = XmlUtility.ReadAttribute(node, "tooltip"); commandName = XmlUtility.ReadAttribute(node, "command"); if (!string.IsNullOrEmpty(commandName)) { _statusMonitor = new CommandStatusMonitor(commandName, enable => Enabled = enable, visible => Visible = visible); } }
public static void GetBuildResources(List <string> resourceList, string pathname, params ResourceType[] filter) { pathname = PathUtility.FormatPath(pathname); if (!Directory.Exists(PathUtility.ProjectPathToFullPath(pathname))) { if (CollectionUtility.Contains(filter, ResourcesUtility.GetResourceTypeByPath(pathname))) { resourceList.Add(pathname); } } else { //SCENES if (pathname.Contains("res/scenes")) { filter = CollectionUtility.Remove(filter, sceneFilterRemoves); } //ALWAYS BUILD else if ( pathname.Contains("res/player") || pathname.Contains("res/bullet") || pathname.Contains("res/enemy") || pathname.Contains("res/effects_tex") || pathname.Contains("res/drawing")) { filter = buildFilter; } //Only Prefabs, No Scenes else { filter = CollectionUtility.Remove(filter, directoryFilterRemoves); } string[] fileList = Directory.GetFiles(pathname, "*"); foreach (string resource in fileList) { if (CollectionUtility.Contains( filter, ResourcesUtility.GetResourceTypeByPath(resource))) { resourceList.Add(PathUtility.FullPathToProjectPath(resource)); } } string[] dictList = Directory.GetDirectories(pathname); foreach (string dictname in dictList) { GetBuildResources(resourceList, dictname, filter); } } }
public ToolBarCommand(XmlNode node, IBundle owner, bool createCommand) { RightToLeft = RightToLeft.Inherit; this.node = node; this.owner = owner; if (createCommand) { LoadClass(); } if (Image == null) { string icon = XmlUtility.ReadAttribute(node, "icon"); if (!string.IsNullOrEmpty(icon)) { Image = ResourcesUtility.TryGetBitmap(owner.LoadResource(icon, ResourceLoadMode.ClassSpace)); } } Text = XmlUtility.ReadAttribute(node, "text"); ToolTipText = XmlUtility.ReadAttribute(node, "tooltip"); }
public static string GetAbName(string path) { ResourceType type = ResourcesUtility.GetResourceTypeByPath(path); //所有shader和material放到一个assetbundle if (type == ResourceType.shader || type == ResourceType.shadervariants) { return(ShaderBundleName); } //检查是否是按文件夹自定义的assetbundleName if (type == ResourceType.scene) { var strAbName = ProjectPathToResourcesPath(path).Replace("/", "_").Replace(".", "_").Replace(" ", "_") + ".haruhi"; return(strAbName.ToLower()); } //检查是否是按文件夹自定义的assetbundleName string abName = CheckCustomPath(path); if (abName != null) { return(abName.ToLower()); } //默认的情况,则按照目录名命名assetbundleName path = ProjectPathToResourcesPath(path); var items = path.Split('/'); path = path.Replace(items[items.Length - 1], "").Replace("/", "_") + ".haruhi"; if (CheckAbNameLength(path)) { return(path.ToLower()); } throw new Exception("he assetbundle name is too long bigger than 100"); }
public static bool SetAssetsBundleName(HashSet <string> rList) { int step = 0; //step 1: 遍历所有依赖, 缓存资源被依赖次数 var dependCount = new Dictionary <string, int>(); var dependResourceList = new Dictionary <string, List <string> >(); foreach (string resource in rList) { var dependenies = AssetDatabase.GetDependencies(resource, true); for (int i = 0; i < dependenies.Length; i++) { var rName = dependenies[i]; if (!dependCount.ContainsKey(rName)) { dependCount[rName] = 1; dependResourceList[rName] = new List <string>(); } else { dependCount[rName]++; } dependResourceList[rName].Add(resource); } ++step; ShowProgressBar("Get DependFileList", resource, step / (float)rList.Count); } step = 0; var e = dependCount.GetEnumerator(); using (e) { while (e.MoveNext()) { //Debug.Log("resource:" + e.Current.Key + " count:" + e.Current.Value); var resource = e.Current.Key; ResourceType type = ResourcesUtility.GetResourceTypeByPath(e.Current.Key); var importer = AssetImporter.GetAtPath(resource); if (importer == null) { Debug.LogError("Error Resource importer is Null. --> " + resource); return(false); } switch (type) { case ResourceType.texture: TextureImporter textureImporter = importer as TextureImporter; var isUiSprite = resource.Contains("ui/textures"); if (isUiSprite && textureImporter != null && textureImporter.textureType == TextureImporterType.Sprite) { importer.assetBundleName = ""; } else { importer.assetBundleName = PathUtility.GetAbName(resource); } break; case ResourceType.scene: case ResourceType.prefab: case ResourceType.fbx: case ResourceType.material: case ResourceType.physicMaterial: case ResourceType.audio: case ResourceType.controller: case ResourceType.font: case ResourceType.mask: case ResourceType.anim: case ResourceType.mp4: case ResourceType.shadervariants: case ResourceType.speedTree: case ResourceType.terrainLayer: case ResourceType.flare: case ResourceType.sbsar: case ResourceType.bytes: case ResourceType.asset: // 光照贴图的ab名称需与unity场景文件ab名称一致 case ResourceType.spriteatlas: importer.assetBundleName = PathUtility.GetAbName(resource); break; case ResourceType.shader: importer.assetBundleName = PathUtility.GetAbName(resource); break; case ResourceType.table: case ResourceType.config: case ResourceType.script: case ResourceType.folder: break; default: importer.assetBundleName = PathUtility.GetAbName(resource); Debug.LogError("unknow depend resource : " + resource + " type:" + type); break; } ++step; ShowProgressBar("Set Resource AssetBundleName", resource, step / (float)dependCount.Count); } } return(true); }
private static Object LoadImpl(string resource) { Object mainObject = null; if (!string.IsNullOrEmpty(resource)) { mainObject = UnityEditor.AssetDatabase.LoadAssetAtPath(PathUtility.GetResourcesPathToProjectPath(resource), ResourcesUtility.TypeOfResource(resource)); if (!mainObject) { Debug.LogError(string.Format("load : {0} faild", resource)); } } return(mainObject); }