UnityEditor.AssetPreview.IsLoadingAssetPreview C# (CSharp) Method

IsLoadingAssetPreview() public static method

Loading previews is asynchronous so it is useful to know if a specific asset preview is in the process of being loaded so client code e.g can repaint while waiting for the loading to finish.

public static IsLoadingAssetPreview ( int instanceID ) : bool
instanceID int InstanceID of the assset that a preview has been requested for by: AssetPreview.GetAssetPreview().
return bool
        public static bool IsLoadingAssetPreview(int instanceID)
        {
            return IsLoadingAssetPreview(instanceID, 0);
        }

Same methods

AssetPreview::IsLoadingAssetPreview ( int instanceID, int clientID ) : bool

Usage Example

示例#1
0
        internal virtual void OnHeaderIconGUI(Rect iconRect)
        {
            Texture2D icon = null;

            if (!HasPreviewGUI())
            {
                //  Fetch isLoadingAssetPreview to ensure that there is no situation where a preview needs a repaint because it hasn't finished loading yet.
                bool isLoadingAssetPreview = AssetPreview.IsLoadingAssetPreview(target.GetInstanceID());
                icon = AssetPreview.GetAssetPreview(target);
                if (!icon)
                {
                    // We have a static preview it just hasn't been loaded yet. Repaint until we have it loaded.
                    if (isLoadingAssetPreview)
                    {
                        Repaint();
                    }
                    icon = AssetPreview.GetMiniThumbnail(target);
                }
            }

            if (HasPreviewGUI())
            {
                // OnPreviewGUI must have all events; not just Repaint, or else the control IDs will mis-match.
                OnPreviewGUI(iconRect, Styles.inspectorBigInner);
            }
            else if (icon)
            {
                GUI.Label(iconRect, icon, Styles.centerStyle);
            }
        }
All Usage Examples Of UnityEditor.AssetPreview::IsLoadingAssetPreview