public static bool ShowInAPlusEnable() { if (Selection.objects == null || Selection.objects.Length == 0) { return(false); } if (Instance == null) { return(false); } HashSet <string> types = new HashSet <string>(); foreach (var item in Selection.objects) { if (item == null) { continue; } types.Add(APResources.GetAssetTypeByObject(item)); } return(types.Count() == 1 && !string.IsNullOrEmpty(types.ElementAt(0))); }
private static void SelectAssetTypeInSelection(string assetType) { List <UnityEngine.Object> objects = new List <UnityEngine.Object>(); foreach (var obj in Selection.objects) { if (assetType.Equals(APResources.GetAssetTypeByObject(obj), StringComparison.CurrentCultureIgnoreCase)) { objects.Add(obj); } } Selection.objects = objects.ToArray(); if (Event.current != null) { Event.current.Use(); } }
public static void ShowInAPlus() { HashSet <string> types = new HashSet <string>(); var ids = Selection.objects.Select(o => { var path = AssetDatabase.GetAssetPath(o); var assetid = AssetDatabase.AssetPathToGUID(path); if (o is AnimationClip) { if (!path.EndsWith(".anim")) { assetid = Utility.GetAssetId(assetid, Utility.GetLocalIndentifierOfObject(o).ToString()); } } types.Add(APResources.GetAssetTypeByObject(o)); return(assetid); }).ToArray(); if (types.Count > 1) { string message = "This actions does not support multiple assets type. Please use 'Select in Selection' in Assets menu to select one type."; EditorUtility.DisplayDialog("Not Support Action", message, "OK"); return; } if (types.Count == 1) { var assetType = types.ElementAt(0); if (string.IsNullOrEmpty(assetType)) { string message = "The assets selected are not supported in currect version."; EditorUtility.DisplayDialog("Not Support Assets", message, "OK"); return; } AssetNotification.webCommunicationService.SetCurrentURL(string.Format("res/{0}", types.ElementAt(0)), string.Format("Id:{0}", string.Join("|", ids))); } }