Beispiel #1
0
            private void DoPreviewPopup(PackageImportTreeView.PackageImportTreeViewItem pitem, Rect rowRect)
            {
                ImportPackageItem item = pitem.item;

                if (item != null)
                {
                    if (Event.current.type == EventType.MouseDown && rowRect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible())
                    {
                        this.showPreviewForID = pitem.id;
                    }
                    if (pitem.id == this.showPreviewForID && Event.current.type != EventType.Layout)
                    {
                        this.showPreviewForID = 0;
                        if (!string.IsNullOrEmpty(item.previewPath))
                        {
                            Texture2D preview = PackageImport.GetPreview(item.previewPath);
                            Rect      rect    = rowRect;
                            rect.width = EditorGUIUtility.currentViewWidth;
                            Rect arg_AF_0 = rect;
                            PopupWindowContent arg_AF_1 = new PackageImportTreeView.PreviewPopup(preview);
                            PopupLocationHelper.PopupLocation[] expr_A7 = new PopupLocationHelper.PopupLocation[3];
                            expr_A7[0] = PopupLocationHelper.PopupLocation.Right;
                            expr_A7[1] = PopupLocationHelper.PopupLocation.Left;
                            PopupWindowWithoutFocus.Show(arg_AF_0, arg_AF_1, expr_A7);
                        }
                    }
                }
            }
            public override Rect OnRowGUI(TreeViewItem node, int row, float rowWidth, bool selected, bool focused)
            {
                Rect rect = new Rect(0f, (float)row * this.k_LineHeight, rowWidth, this.k_LineHeight);

                this.DoNodeGUI(rect, node, selected, focused, false);
                PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = node as PackageImportTreeView.PackageImportTreeViewItem;
                if (packageImportTreeViewItem != null)
                {
                    Rect toggleRect = new Rect(2f, rect.y, rect.height, rect.height);
                    EditorGUI.BeginChangeCheck();
                    PackageImportTreeView.PackageImportTreeViewGUI.Toggle(packageImportTreeViewItem, toggleRect);
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (this.m_TreeView.GetSelection().Length <= 1 || !this.m_TreeView.GetSelection().Contains(packageImportTreeViewItem.id))
                        {
                            this.m_TreeView.SetSelection(new int[]
                            {
                                packageImportTreeViewItem.id
                            }, false);
                            this.m_TreeView.NotifyListenersThatSelectionChanged();
                        }
                        if (this.itemWasToggled != null)
                        {
                            this.itemWasToggled(packageImportTreeViewItem);
                        }
                        Event.current.Use();
                    }
                    if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible())
                    {
                        this.showPreviewForID = packageImportTreeViewItem.id;
                    }
                    if (packageImportTreeViewItem.id == this.showPreviewForID && Event.current.type != EventType.Layout)
                    {
                        this.showPreviewForID = 0;
                        if (!string.IsNullOrEmpty(packageImportTreeViewItem.item.previewPath))
                        {
                            Texture2D preview = PackageImport.GetPreview(packageImportTreeViewItem.item.previewPath);
                            Rect      rect2   = rect;
                            rect2.width = EditorGUIUtility.currentViewWidth;
                            Rect arg_190_0 = rect2;
                            PopupWindowContent arg_190_1 = new PackageImportTreeView.PreviewPopup(preview);
                            PopupLocationHelper.PopupLocation[] expr_188 = new PopupLocationHelper.PopupLocation[3];
                            expr_188[0] = PopupLocationHelper.PopupLocation.Right;
                            expr_188[1] = PopupLocationHelper.PopupLocation.Left;
                            PopupWindowWithoutFocus.Show(arg_190_0, arg_190_1, expr_188);
                        }
                    }
                    if (packageImportTreeViewItem.item.exists == 0)
                    {
                        Texture image = this.constants.badgeNew.image;
                        GUI.DrawTexture(new Rect(rect.xMax - (float)image.width - 6f, rect.y + (rect.height - (float)image.height) / 2f, (float)image.width, (float)image.height), image);
                    }
                }
                return(rect);
            }
			public override Rect OnRowGUI(TreeViewItem node, int row, float rowWidth, bool selected, bool focused)
			{
				Rect rect = new Rect(0f, (float)row * this.k_LineHeight, rowWidth, this.k_LineHeight);
				this.DoNodeGUI(rect, node, selected, focused, false);
				PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = node as PackageImportTreeView.PackageImportTreeViewItem;
				if (packageImportTreeViewItem != null)
				{
					Rect toggleRect = new Rect(2f, rect.y, rect.height, rect.height);
					EditorGUI.BeginChangeCheck();
					PackageImportTreeView.PackageImportTreeViewGUI.Toggle(packageImportTreeViewItem, toggleRect);
					if (EditorGUI.EndChangeCheck())
					{
						if (this.m_TreeView.GetSelection().Length <= 1 || !this.m_TreeView.GetSelection().Contains(packageImportTreeViewItem.id))
						{
							this.m_TreeView.SetSelection(new int[]
							{
								packageImportTreeViewItem.id
							}, false);
							this.m_TreeView.NotifyListenersThatSelectionChanged();
						}
						if (this.itemWasToggled != null)
						{
							this.itemWasToggled(packageImportTreeViewItem);
						}
						Event.current.Use();
					}
					if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible())
					{
						this.showPreviewForID = packageImportTreeViewItem.id;
					}
					if (packageImportTreeViewItem.id == this.showPreviewForID && Event.current.type != EventType.Layout)
					{
						this.showPreviewForID = 0;
						if (!string.IsNullOrEmpty(packageImportTreeViewItem.item.previewPath))
						{
							Texture2D preview = PackageImport.GetPreview(packageImportTreeViewItem.item.previewPath);
							Rect rect2 = rect;
							rect2.width = EditorGUIUtility.currentViewWidth;
							Rect arg_190_0 = rect2;
							PopupWindowContent arg_190_1 = new PackageImportTreeView.PreviewPopup(preview);
							PopupLocationHelper.PopupLocation[] expr_188 = new PopupLocationHelper.PopupLocation[3];
							expr_188[0] = PopupLocationHelper.PopupLocation.Right;
							expr_188[1] = PopupLocationHelper.PopupLocation.Left;
							PopupWindowWithoutFocus.Show(arg_190_0, arg_190_1, expr_188);
						}
					}
					if (packageImportTreeViewItem.item.exists == 0)
					{
						Texture image = this.constants.badgeNew.image;
						GUI.DrawTexture(new Rect(rect.xMax - (float)image.width - 6f, rect.y + (rect.height - (float)image.height) / 2f, (float)image.width, (float)image.height), image);
					}
				}
				return rect;
			}