获取对象的预览图——AssetPreview.GetAssetPreview()

作者:追风剑情 发布于:2017-12-27 17:49 分类:Unity3d

获取对象的预览图

示例代码


using UnityEngine;
using UnityEditor;
using System.Collections;

public class AssetPreviewWindow : EditorWindow
{
    [MenuItem("Example/AssetPreviewWindow")]
    static void Init()
    {
        EditorWindow window = EditorWindow.CreateInstance<AssetPreviewWindow>();
        window.Show();
    }

    void OnGUI()
    {
        Texture2D previewTex = AssetPreview.GetAssetPreview(Selection.activeObject);
        EditorGUILayout.BeginVertical();
        GUILayout.SelectionGrid(0, new Texture2D[] { previewTex }, 1);//显示所选对象的预览图
        EditorGUILayout.EndVertical();
    }
}


效果

1111.png

标签: Unity3d

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号