/************************************************/ /* */ /* Copyright (c) 2018 - 2021 monitor1394 */ /* https://github.com/monitor1394 */ /* */ /************************************************/ using System; using UnityEngine; using UnityEngine.UI; namespace XCharts { public class LegendItem { private int m_Index; private string m_Name; private string m_LegendName; private GameObject m_GameObject; private Button m_Button; private Image m_Icon; private ChartText m_Text; private Image m_TextBackground; private RectTransform m_Rect; private RectTransform m_IconRect; private RectTransform m_TextRect; private RectTransform m_TextBackgroundRect; private float m_Gap = 0f; private float m_LabelPaddingLeftRight = 0f; private float m_LabelPaddingTopBottom = 0f; private bool m_LabelAutoSize = true; public int index { get { return m_Index; } set { m_Index = value; } } public string name { get { return m_Name; } set { m_Name = value; } } public string legendName { get { return m_LegendName; } set { m_LegendName = value; } } public GameObject gameObject { get { return m_GameObject; } } public Button button { get { return m_Button; } } public float width { get { if (m_IconRect && m_TextBackgroundRect) { return m_IconRect.sizeDelta.x + m_Gap + m_TextBackgroundRect.sizeDelta.x; } else { return 0; } } } public float height { get { if (m_IconRect && m_TextBackgroundRect) { return Mathf.Max(m_IconRect.sizeDelta.y, m_TextBackgroundRect.sizeDelta.y); } else { return 0; } } } public void SetObject(GameObject obj) { m_GameObject = obj; m_Button = obj.GetComponent