bazi

C#根据模型生成图片

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class ExportPng : 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/Image/image_" + i + ".png", image.EncodeToPNG());
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

 

posted on 2023-02-25 08:40  芭梓  阅读(55)  评论(0编辑  收藏  举报

导航