add tooltip delegate function: positionFunction

This commit is contained in:
monitor1394
2021-11-27 22:06:15 +08:00
parent cc72f303f1
commit 4d6e896d32
4 changed files with 25 additions and 3 deletions

View File

@@ -65,6 +65,7 @@ namespace XCharts
[SerializeField] private Sprite m_BackgroundImage;
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
[SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.None);
private DelegateTooltipPosition m_PositionFunction;
private GameObject m_GameObject;
private GameObject m_Content;
@@ -300,6 +301,12 @@ namespace XCharts
public int runtimeGridIndex { get; internal set; }
public int runtimePolarIndex { get; internal set; }
public DelegateTooltipPosition positionFunction
{
get { return m_PositionFunction; }
set { m_PositionFunction = value; }
}
public static Tooltip defaultTooltip
{
get
@@ -449,7 +456,12 @@ namespace XCharts
public void UpdateContentPos(Vector2 pos)
{
if (m_Content)
m_Content.transform.localPosition = pos;
{
if (m_PositionFunction != null)
m_Content.transform.localPosition = m_PositionFunction(pos);
else
m_Content.transform.localPosition = pos;
}
}
/// <summary>