using UnityEditor;
using UnityEngine;
/// <summary>
/// 将预制体转个图片出来
/// </summary>
public class ExportPicture : MonoBehaviour
{
    public GameObject[] prefabs;
    // Start is called before the first frame update
    void Start()
    {
        for (int i = 0; i < prefabs.Length; i++)
        {
            EditorUtility.SetDirty(prefabs[i]);
            Texture2D image = AssetPreview.GetAssetPreview(prefabs[i]);
            System.IO.File.WriteAllBytes(Application.dataPath + "/Resources/Images/YIFU_" + i + ".png", image.EncodeToPNG());//存入位置
        }
    }
}

 

posted on 2023-03-08 14:20  a帝  阅读(18)  评论(0编辑  收藏  举报