GetAssetPreview return null

I want to dynamic generate preview images for every models for my software, so that my software can have preview images before loading models. I want to do this step in editor.

It’s an MenuItem function. The object is prefab (I tried it as GameObject and Object). I try using GetAssetPreview() to generate preview texture, but it’s always null. I know it’s asynchronously, so i tried using loop with Thread.Sleep and Enumerator,and wait for more than 5 seconds. Didn’t work. AssetPreview.IsLoadingAssetPreview() is false. AssetPreview.IsLoadingAssetPreviews() is also false.

Any suggestions?

I end up using PreviewRenderUtility. a lot of steps, but flexible