mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-19 06:50:18 +00:00
Merge branch 'master' of https://github.com/monitor1394/unity-ugui-XCharts
This commit is contained in:
@@ -161,12 +161,13 @@ namespace XCharts
|
||||
rect.anchorMin = anchorMin;
|
||||
rect.anchorMax = anchorMax;
|
||||
rect.pivot = pivot;
|
||||
rect.anchoredPosition3D = Vector3.zero;
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static Text AddTextObject(string name, Transform parent, Font font, Color color,
|
||||
TextAnchor anchor, Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot, Vector2 sizeDelta,
|
||||
int fontSize = 14, float rotate = 0, FontStyle fontStyle = FontStyle.Normal)
|
||||
int fontSize = 14, float rotate = 0, FontStyle fontStyle = FontStyle.Normal, float lineSpacing = 1)
|
||||
{
|
||||
GameObject txtObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
|
||||
Text txt = GetOrAddComponent<Text>(txtObj);
|
||||
@@ -178,6 +179,7 @@ namespace XCharts
|
||||
txt.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||||
txt.verticalOverflow = VerticalWrapMode.Overflow;
|
||||
txt.color = color;
|
||||
txt.lineSpacing = lineSpacing;
|
||||
txtObj.transform.localEulerAngles = new Vector3(0, 0, rotate);
|
||||
|
||||
RectTransform rect = GetOrAddComponent<RectTransform>(txtObj);
|
||||
@@ -191,20 +193,21 @@ namespace XCharts
|
||||
|
||||
public static Button AddButtonObject(string name, Transform parent, Font font, int fontSize,
|
||||
Color color, TextAnchor anchor, Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot,
|
||||
Vector2 sizeDelta)
|
||||
Vector2 sizeDelta, float lineSpacing)
|
||||
{
|
||||
GameObject btnObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
|
||||
GetOrAddComponent<Image>(btnObj);
|
||||
GetOrAddComponent<Button>(btnObj);
|
||||
Text txt = AddTextObject("Text", btnObj.transform, font, color, TextAnchor.MiddleCenter,
|
||||
new Vector2(0, 0), new Vector2(1, 1), new Vector2(0.5f, 0.5f),
|
||||
sizeDelta, fontSize);
|
||||
sizeDelta, fontSize, lineSpacing);
|
||||
txt.rectTransform.offsetMin = Vector2.zero;
|
||||
txt.rectTransform.offsetMax = Vector2.zero;
|
||||
return btnObj.GetComponent<Button>();
|
||||
}
|
||||
|
||||
internal static GameObject AddTooltipContent(string name, Transform parent, Font font, int fontSize, FontStyle fontStyle)
|
||||
internal static GameObject AddTooltipContent(string name, Transform parent, Font font, int fontSize,
|
||||
FontStyle fontStyle, float lineSpacing)
|
||||
{
|
||||
var anchorMax = new Vector2(0, 1);
|
||||
var anchorMin = new Vector2(0, 1);
|
||||
@@ -214,7 +217,7 @@ namespace XCharts
|
||||
var img = GetOrAddComponent<Image>(tooltipObj);
|
||||
img.color = Color.black;
|
||||
Text txt = AddTextObject("Text", tooltipObj.transform, font, Color.white, TextAnchor.UpperLeft,
|
||||
anchorMin, anchorMax, pivot, sizeDelta, fontSize, 0, fontStyle);
|
||||
anchorMin, anchorMax, pivot, sizeDelta, fontSize, 0, fontStyle, lineSpacing);
|
||||
txt.text = "Text";
|
||||
txt.transform.localPosition = new Vector2(3, -3);
|
||||
tooltipObj.transform.localPosition = Vector3.zero;
|
||||
@@ -232,8 +235,9 @@ namespace XCharts
|
||||
return iconObj;
|
||||
}
|
||||
|
||||
internal static GameObject AddSerieLabel(string name, Transform parent, Font font, Color textColor, Color backgroundColor,
|
||||
int fontSize, FontStyle fontStyle, float rotate, float width, float height)
|
||||
internal static GameObject AddSerieLabel(string name, Transform parent, Font font, Color textColor,
|
||||
Color backgroundColor, int fontSize, FontStyle fontStyle, float rotate, float width, float height,
|
||||
float lineSpacing)
|
||||
{
|
||||
var anchorMin = new Vector2(0.5f, 0.5f);
|
||||
var anchorMax = new Vector2(0.5f, 0.5f);
|
||||
@@ -244,7 +248,7 @@ namespace XCharts
|
||||
//img.color = backgroundColor;
|
||||
labelObj.transform.localEulerAngles = new Vector3(0, 0, rotate);
|
||||
Text txt = AddTextObject("Text", labelObj.transform, font, textColor, TextAnchor.MiddleCenter,
|
||||
anchorMin, anchorMax, pivot, sizeDelta, fontSize, 0, fontStyle);
|
||||
anchorMin, anchorMax, pivot, sizeDelta, fontSize, 0, fontStyle, lineSpacing);
|
||||
txt.text = "Text";
|
||||
txt.transform.localPosition = new Vector2(0, 0);
|
||||
txt.transform.localEulerAngles = Vector3.zero;
|
||||
@@ -269,7 +273,6 @@ namespace XCharts
|
||||
return labelObj;
|
||||
}
|
||||
|
||||
|
||||
public static void GetPointList(ref List<Vector3> posList, Vector3 sp, Vector3 ep, float k = 30f)
|
||||
{
|
||||
Vector3 dir = (ep - sp).normalized;
|
||||
@@ -396,11 +399,30 @@ namespace XCharts
|
||||
if (list1.Count != list2.Count) return false;
|
||||
for (int i = 0; i < list1.Count; i++)
|
||||
{
|
||||
if (!list1[i].Equals(list2[i])) return false;
|
||||
if (list1[i] == null && list2[i] == null) { }
|
||||
else
|
||||
{
|
||||
if (list1[i] != null)
|
||||
{
|
||||
if (!list1[i].Equals(list2[i])) return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!list2[i].Equals(list1[i])) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CopyList<T>(List<T> toList, List<T> fromList)
|
||||
{
|
||||
if (toList == null || fromList == null) return false;
|
||||
toList.Clear();
|
||||
foreach (var item in fromList) toList.Add(item);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static List<float> ParseFloatFromString(string jsonData)
|
||||
{
|
||||
List<float> list = new List<float>();
|
||||
|
||||
Reference in New Issue
Block a user