首页 > 其他分享 >将预制体转个图片出来

将预制体转个图片出来

时间:2023-03-08 14:36:59浏览次数:37  
标签:prefabs image Start 体转个 预制 public 图片

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());//存入位置
        }
    }
}

 

标签:prefabs,image,Start,体转个,预制,public,图片
From: https://www.cnblogs.com/z816/p/17191877.html

相关文章