修复SaveAsImage被其他组件遮挡时无法正常保存的问题 (#337)

This commit is contained in:
monitor1394
2026-02-26 21:53:29 +08:00
parent 92abee1a6c
commit 3301d5fd36
7 changed files with 363 additions and 25 deletions

View File

@@ -209,15 +209,20 @@ namespace XCharts.Runtime
/// </summary>
/// <param name="imageType">type of image: png, jpg, exr</param>
/// <param name="savePath">save path</param>
public void SaveAsImage(string imageType = "png", string savePath = "")
/// <param name="exportScale">export resolution scale. 1 means original size</param>
/// <param name="useRecursiveBackgroundColor">whether to recursively use lower-level UI background color</param>
public void SaveAsImage(string imageType = "png", string savePath = "", float exportScale = 1f,
bool useRecursiveBackgroundColor = false)
{
StartCoroutine(SaveAsImageSync(imageType, savePath));
StartCoroutine(SaveAsImageSync(imageType, savePath, exportScale, useRecursiveBackgroundColor));
}
private IEnumerator SaveAsImageSync(string imageType, string path)
private IEnumerator SaveAsImageSync(string imageType, string path, float exportScale,
bool useRecursiveBackgroundColor)
{
yield return new WaitForEndOfFrame();
ChartHelper.SaveAsImage(rectTransform, canvas, imageType, path);
ChartHelper.SaveAsImage(rectTransform, canvas, imageType, path, exportScale,
useRecursiveBackgroundColor);
}
public Vector3 GetTitlePosition(Title title)