using Godot;
using System;

[Tool]
public partial class ImageSave : TextureRect
{
	[ExportToolButton("导出图片")]
	public Callable clickMeBtn => Callable.From(ComputeStat);
	[Export] public string imageName { get; set; } = "icon";
	[Export] int index = 1;
	void ComputeStat()
	{
		var path = $"res://Assets/Icon/{imageName + index}.png";
		GD.Print($"保存图片{path}");
		var image = Texture.GetImage();
		image.SavePng(path);
		index++;
	}
	// Called every frame. 'delta' is the elapsed time since the previous frame.
	public override void _Process(double delta)
	{
	}
}

Logo

一站式虚拟内容创作平台,激发创意,赋能创作,进入R空间,遇见同道,让优质作品闪耀发光。​

更多推荐