mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-22 08:50:10 +00:00
代码优化
This commit is contained in:
@@ -631,15 +631,5 @@ namespace XCharts.Runtime
|
|||||||
SerieHelper.GetItemColor(out color, out toColor, serie, null, m_Theme);
|
SerieHelper.GetItemColor(out color, out toColor, serie, null, m_Theme);
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 保存图表为图片。
|
|
||||||
/// </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 = "")
|
|
||||||
{
|
|
||||||
StartCoroutine(SaveAsImageSync(imageType, savePath));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -746,11 +746,5 @@ namespace XCharts.Runtime
|
|||||||
InitComponentHandlers();
|
InitComponentHandlers();
|
||||||
InitSerieHandlers();
|
InitSerieHandlers();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerator SaveAsImageSync(string imageType, string path)
|
|
||||||
{
|
|
||||||
yield return new WaitForEndOfFrame();
|
|
||||||
ChartHelper.SaveAsImage(rectTransform, canvas, imageType, path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
@@ -170,5 +171,21 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存图表为图片。
|
||||||
|
/// </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 = "")
|
||||||
|
{
|
||||||
|
StartCoroutine(SaveAsImageSync(imageType, savePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerator SaveAsImageSync(string imageType, string path)
|
||||||
|
{
|
||||||
|
yield return new WaitForEndOfFrame();
|
||||||
|
ChartHelper.SaveAsImage(rectTransform, canvas, imageType, path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,7 @@ namespace XCharts.Runtime
|
|||||||
public bool hideIconIfTextEmpty { set { m_HideIconIfTextEmpty = value; } }
|
public bool hideIconIfTextEmpty { set { m_HideIconIfTextEmpty = value; } }
|
||||||
public bool isIconActive { get; private set; }
|
public bool isIconActive { get; private set; }
|
||||||
public bool isAnimationEnd { get; internal set; }
|
public bool isAnimationEnd { get; internal set; }
|
||||||
|
public Rect rect { get; set; }
|
||||||
|
|
||||||
internal RectTransform objectRect
|
internal RectTransform objectRect
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace XCharts.Runtime
|
|||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void CheckRefresh()
|
public void CheckRefresh()
|
||||||
{
|
{
|
||||||
if (m_Refresh && gameObject.activeSelf)
|
if (m_Refresh && gameObject.activeSelf)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -324,14 +324,20 @@ namespace XCharts.Runtime
|
|||||||
if (background == null) return;
|
if (background == null) return;
|
||||||
if (imageStyle.show)
|
if (imageStyle.show)
|
||||||
{
|
{
|
||||||
|
background.gameObject.SetActive(true);
|
||||||
background.sprite = imageStyle.sprite;
|
background.sprite = imageStyle.sprite;
|
||||||
background.color = imageStyle.color;
|
background.color = imageStyle.color;
|
||||||
background.type = imageStyle.type;
|
background.type = imageStyle.type;
|
||||||
|
if (imageStyle.width > 0 && imageStyle.height > 0)
|
||||||
|
{
|
||||||
|
background.rectTransform.sizeDelta = new Vector2(imageStyle.width, imageStyle.height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
background.sprite = null;
|
background.sprite = null;
|
||||||
background.color = Color.clear;
|
background.color = Color.clear;
|
||||||
|
background.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user