UnityEditor.PackageImport.GetPreview C# (CSharp) Method

GetPreview() public static method

public static GetPreview ( string previewPath ) : Texture2D
previewPath string
return UnityEngine.Texture2D
        public static Texture2D GetPreview(string previewPath)
        {
            if (previewPath != s_LastPreviewPath)
            {
                s_LastPreviewPath = previewPath;
                LoadTexture(previewPath, ref s_Preview);
            }
            return s_Preview;
        }

Usage Example

            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      activatorRect = rowRect;
                            activatorRect.width = EditorGUIUtility.currentViewWidth;
                            PopupLocationHelper.PopupLocation[] locationPriorityOrder = new PopupLocationHelper.PopupLocation[3];
                            locationPriorityOrder[0] = PopupLocationHelper.PopupLocation.Right;
                            locationPriorityOrder[1] = PopupLocationHelper.PopupLocation.Left;
                            PopupWindowWithoutFocus.Show(activatorRect, new PackageImportTreeView.PreviewPopup(preview), locationPriorityOrder);
                        }
                    }
                }
            }
All Usage Examples Of UnityEditor.PackageImport::GetPreview