Search Unity

AssetPreview.GetAssetPreview(Selection.activeGameObject); is always null

Discussion in 'Immediate Mode GUI (IMGUI)' started by phoenixrising, Aug 19, 2015.

  1. phoenixrising

    phoenixrising

    Joined:
    Aug 9, 2013
    Posts:
    57
    I am trying to get the AssetPreview.GetAssetPreview(Selection.activeGameObject); texture but it is always returning null.

    Does anyone know how I can get the AssetPreview.GetAssetPreview(Selection.activeGameObject);???



    Code (CSharp):
    1.     void OnGUI () {  
    2.         int counter = 0;
    3.         if(Selection.activeGameObject!=null)
    4.             GUILayout.Label (Selection.activeGameObject.name+" is ready "+Selection.activeGameObject.GetInstanceID());
    5.         else
    6.             GUILayout.Label ("its null");
    7.  
    8.         while(AssetPreview.IsLoadingAssetPreviews() && counter<1000000)
    9.             counter++;
    10.        
    11.         if(texThumb==null)
    12.             texThumb=AssetPreview.GetAssetPreview(Selection.activeGameObject);
    13.        
    14.         if(texThumb!=null)
    15.             GUILayout.Label(texThumb);
    16.         else
    17.             GUILayout.Label ("its still null ");          
    18.     }
    19.  
     
    Xarbrough likes this.