AAń2018.1.6f1ţ˙˙˙˙˙’3$řĚuń옲e+ Í=^7€˙˙˙˙€Ś€˛€ЀŚ€Ś€Ś€#Ś€+H€3˙˙˙˙€1€1€˙˙˙˙@ހ€ Q€j€ H€<˙˙˙˙ €1€1€˙˙˙˙ @ހ€ Q€j€Ő€I˙˙˙˙€1€1€˙˙˙˙Ŕހ€H€j€˙˙˙˙€1€1€˙˙˙˙@ހ€Q€j€™€PAssetMetaDataguiddata[0]data[1]data[2]data[3]pathNameoriginalNamelabelsassetStoreRef ˙˙ŢšőRkVc}­j˘9Ź­;Ę7€˙˙˙˙€Ś€˛€ Ő€ ހ#€.€,€†€Ä€ ހ#€.€,€H€Ť€˙˙˙˙€1€1€˙˙˙˙ @ހ€ Q€j€ ń€5˙˙˙˙ €1€1€˙˙˙˙ €ހ€€j€˙˙˙˙€G›€˙˙˙˙€H€]˙˙˙˙€1€1€˙˙˙˙@ހ€Q€j€H€b˙˙˙˙€1€1€˙˙˙˙@ހ€Q€j€H€k˙˙˙˙€1€1€˙˙˙˙@ހ€Q€j€y€ € ހ#€.€,€Ő€p˙˙˙˙ €1€1€˙˙˙˙!Ŕހ€"€j€˙˙˙˙#€H€›€˙˙˙˙$€1€1€˙˙˙˙%@ހ€&Q€j€'y€ € (ހ#)€.€,*€ €„+@ž€“ ,@ހ#-€.€,.€H€˜˙˙˙˙/€1€1€˙˙˙˙0@ހ€1Q€j€2H€Ł˙˙˙˙3€1€1€˙˙˙˙4@ހ€5Q€j€6H€ľ˙˙˙˙7€1€1€˙˙˙˙8@ހ€9Q€j€:MonoImporterPPtrm_FileIDm_PathIDm_ExternalObjectsSourceAssetIdentifiertypeassemblynamem_DefaultReferencesexecutionOrdericonm_UserDatam_AssetBundleNamem_AssetBundleVariants˙˙˙8-l'€Łć„hŒÎA,Œ€7€˙˙˙˙€Ś€˛€Ő€ ހ€.€€†€Ä€ ހ€.€€H€Ť€˙˙˙˙€1€1€˙˙˙˙ @ހ€ Q€j€ H€ę€˙˙˙˙ €1€1€˙˙˙˙ @ހ€Q€j€ń€(˙˙˙˙€1€1€˙˙˙˙€ހ€€j€˙˙˙˙€H€›€˙˙˙˙€1€1€˙˙˙˙@ހ€Q€j€y€ € ހ€.€€y€< ހ€.€€ހCH€T˙˙˙˙€1€1€˙˙˙˙ @ހ€!Q€j€"H€`˙˙˙˙#€1€1€˙˙˙˙$@ހ€%Q€j€&H€l˙˙˙˙'€1€1€˙˙˙˙(@ހ€)Q€j€*L€{+PPtrm_FileIDm_PathIDm_DefaultReferencesm_Iconm_ExecutionOrderm_ClassNamem_Namespacem_AssemblyNamem_IsEditorScriptppDŕyŻ¸91Ňw+](xMŚŚÂhąĎňFPackages/com.unity.package-manager-ui/Editor/Sources/UI/PackageList.cs PackageList—0using UnityEngine.Experimental.UIElements; using System; using System.Collections.Generic; using System.Linq; using UnityEngine; namespace UnityEditor.PackageManager.UI { internal class PackageListFactory : UxmlFactory { protected override PackageList DoCreate(IUxmlAttributes bag, CreationContext cc) { return new PackageList(); } } internal class PackageList : VisualElement { public event Action OnSelected = delegate { }; public event Action OnLoaded = delegate { }; private readonly VisualElement root; private const string emptyId = "emptyArea"; private const string loadingId = "loadingAreaContainer"; private const string loadingSpinnerId = "loadingSpinnerContainer"; private PackageItem selectedItem; private List Groups; public PackageList() { Groups = new List(); root = Resources.Load("Templates/PackageList").CloneTree(null); Add(root); root.StretchToParentSize(); root.Q(emptyId).visible = false; root.Q(loadingId).visible = true; root.Q(loadingId).StretchToParentSize(); root.Q(loadingSpinnerId).clippingOptions = ClippingOptions.NoClipping; LoadingSpinner.Start(); PackageCollection.Instance.OnPackagesChanged += SetPackages; PackageCollection.Instance.OnFilterChanged += OnFilterChanged; RegisterCallback(OnEnterPanel); RegisterCallback(OnLeavePanel); Reload(); } private void OnEnterPanel(AttachToPanelEvent e) { panel.visualTree.RegisterCallback(OnKeyDownShortcut); } private void OnLeavePanel(DetachFromPanelEvent e) { panel.visualTree.UnregisterCallback(OnKeyDownShortcut); } private void ScrollIfNeeded() { if (selectedItem == null) return; var minY = List.worldBound.yMin; var maxY = List.worldBound.yMax; var itemMinY = selectedItem.worldBound.yMin; var itemMaxY = selectedItem.worldBound.yMax; var scroll = List.scrollOffset; if (itemMinY < minY) { scroll.y -= minY - itemMinY; List.scrollOffset = scroll; } else if (itemMaxY > maxY) { scroll.y += itemMaxY - maxY; List.scrollOffset = scroll; } } private void OnKeyDownShortcut(KeyDownEvent evt) { if (selectedItem == null) return; if (evt.keyCode == KeyCode.UpArrow) { if (selectedItem.previousItem != null) { Select(selectedItem.previousItem); ScrollIfNeeded(); } else if (selectedItem.packageGroup != null && selectedItem.packageGroup.previousGroup != null) { selectedItem.packageGroup.previousGroup.SetCollapsed(false); Select(selectedItem.packageGroup.previousGroup.lastPackage); ScrollIfNeeded(); } evt.StopPropagation(); return; } if (evt.keyCode == KeyCode.DownArrow) { if (selectedItem.nextItem != null) { Select(selectedItem.nextItem); ScrollIfNeeded(); } else if (selectedItem.packageGroup != null && selectedItem.packageGroup.nextGroup != null) { selectedItem.packageGroup.nextGroup.SetCollapsed(false); Select(selectedItem.packageGroup.nextGroup.firstPackage); ScrollIfNeeded(); } evt.StopPropagation(); return; } #if UNITY_2018_2_OR_NEWER if (evt.keyCode == KeyCode.LeftArrow) { if (selectedItem.packageGroup != null) { if (!selectedItem.packageGroup.Collapsed) { selectedItem.packageGroup.SetCollapsed(true); if (selectedItem.packageGroup.nextGroup != null) { selectedItem.packageGroup.nextGroup.SetCollapsed(false); Select(selectedItem.packageGroup.nextGroup.firstPackage); ScrollIfNeeded(); } else if (selectedItem.packageGroup.previousGroup != null) { selectedItem.packageGroup.previousGroup.SetCollapsed(false); Select(selectedItem.packageGroup.previousGroup.lastPackage); ScrollIfNeeded(); } } } evt.StopPropagation(); return; } #endif if (evt.keyCode == KeyCode.PageUp) { if (selectedItem.packageGroup != null) { if (selectedItem == selectedItem.packageGroup.lastPackage && selectedItem != selectedItem.packageGroup.firstPackage) { Select(selectedItem.packageGroup.firstPackage); ScrollIfNeeded(); } else if (selectedItem == selectedItem.packageGroup.firstPackage && selectedItem.packageGroup.previousGroup != null) { if (selectedItem.packageGroup.previousGroup.Collapsed) selectedItem.packageGroup.previousGroup.SetCollapsed(false); Select(selectedItem.packageGroup.previousGroup.lastPackage); ScrollIfNeeded(); } else if (selectedItem != selectedItem.packageGroup.lastPackage && selectedItem != selectedItem.packageGroup.firstPackage) { Select(selectedItem.packageGroup.firstPackage); ScrollIfNeeded(); } } evt.StopPropagation(); return; } if (evt.keyCode == KeyCode.PageDown) { if (selectedItem.packageGroup != null) { if (selectedItem == selectedItem.packageGroup.firstPackage && selectedItem != selectedItem.packageGroup.lastPackage) { Select(selectedItem.packageGroup.lastPackage); ScrollIfNeeded(); } else if (selectedItem == selectedItem.packageGroup.lastPackage && selectedItem.packageGroup.nextGroup != null) { if (selectedItem.packageGroup.nextGroup.Collapsed) selectedItem.packageGroup.nextGroup.SetCollapsed(false); Select(selectedItem.packageGroup.nextGroup.firstPackage); ScrollIfNeeded(); } else if (selectedItem != selectedItem.packageGroup.firstPackage && selectedItem != selectedItem.packageGroup.lastPackage) { Select(selectedItem.packageGroup.lastPackage); ScrollIfNeeded(); } } evt.StopPropagation(); } } private void OnFilterChanged(PackageFilter filter) { ClearAll(); if (!LoadingSpinner.Started) { root.Q(loadingId).visible = true; LoadingSpinner.Start(); } } private static void Reload() { // Force a re-init to initial condition PackageCollection.Instance.SetFilter(PackageFilter.Local, false); PackageCollection.Instance.UpdatePackageCollection(true); } private void ClearAll() { List.Clear(); Groups.Clear(); ClearSelection(); root.Q(emptyId).visible = false; if (LoadingSpinner.Started) { root.Q(loadingId).visible = false; LoadingSpinner.Stop(); } } private void SetPackages(IEnumerable packages) { if (PackageCollection.Instance.Filter == PackageFilter.Local) { packages = packages.Where(pkg => pkg.Current != null); } var previousSelection = selectedItem != null ? selectedItem.package : null; OnLoaded(); ClearAll(); var packagesGroup = new PackageGroup(PackageGroupOrigins.Packages.ToString()); Groups.Add(packagesGroup); List.Add(packagesGroup); var builtInGroup = new PackageGroup(PackageGroupOrigins.BuiltInPackages.ToString()); Groups.Add(builtInGroup); List.Add(builtInGroup); packagesGroup.previousGroup = null; #if UNITY_2018_2_OR_NEWER packagesGroup.nextGroup = builtInGroup; builtInGroup.previousGroup = packagesGroup; builtInGroup.nextGroup = null; #else packagesGroup.nextGroup = null; UIUtils.SetElementDisplay(builtInGroup, false); #endif root.Q(loadingId).visible = false; LoadingSpinner.Stop(); foreach (var package in packages.OrderBy(pkg => pkg.Versions.FirstOrDefault() == null ? pkg.Name : pkg.Versions.FirstOrDefault().DisplayName)) { var item = AddPackage(package); if (previousSelection != null && package.Name == previousSelection.Name) Select(item); } root.Q(emptyId).visible = !packages.Any(); } private PackageItem AddPackage(Package package) { var groupName = package.Latest.Group; var group = GetOrCreateGroup(groupName); var packageItem = group.AddPackage(package); if (selectedItem == null && !group.Collapsed) Select(packageItem); packageItem.OnSelected += Select; return packageItem; } private PackageGroup GetOrCreateGroup(string groupName) { foreach (var g in Groups) { if (g.name == groupName) return g; } var group = new PackageGroup(groupName); var latestGroup = Groups.LastOrDefault(); Groups.Add(group); List.Add(group); group.previousGroup = null; if (latestGroup != null) { latestGroup.nextGroup = group; group.previousGroup = latestGroup; group.nextGroup = null; } return group; } private void ClearSelection() { Select(null); } private void Select(PackageItem packageItem) { if (packageItem == selectedItem) return; if (selectedItem != null) selectedItem.SetSelected(false); // Clear Previous selection selectedItem = packageItem; if (selectedItem == null) return; selectedItem.SetSelected(true); OnSelected(selectedItem.package); } private ScrollView List { get { return root.Q("scrollView"); } } private LoadingSpinner LoadingSpinner { get { return root.Q("loadingSpinner"); } } } } PackageListUnityEditor.PackageManager.UI!Unity.PackageManagerUI.Editor.dll