mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-22 00:20:18 +00:00
优化Legend初始化,防止出现预设下删除异常的问题
This commit is contained in:
@@ -108,7 +108,6 @@ namespace XCharts
|
||||
if (go != null)
|
||||
{
|
||||
GameObject.DestroyImmediate(go.gameObject);
|
||||
//GameObject.Destroy(go.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,7 +139,7 @@ namespace XCharts
|
||||
}
|
||||
|
||||
public static GameObject AddObject(string name, Transform parent, Vector2 anchorMin,
|
||||
Vector2 anchorMax, Vector2 pivot, Vector2 sizeDelta)
|
||||
Vector2 anchorMax, Vector2 pivot, Vector2 sizeDelta, int replaceIndex = -1)
|
||||
{
|
||||
GameObject obj;
|
||||
if (parent.Find(name))
|
||||
@@ -150,6 +149,12 @@ namespace XCharts
|
||||
obj.transform.localPosition = Vector3.zero;
|
||||
obj.transform.localScale = Vector3.one;
|
||||
}
|
||||
else if (replaceIndex >= 0 && replaceIndex < parent.childCount)
|
||||
{
|
||||
obj = parent.GetChild(replaceIndex).gameObject;
|
||||
if (!obj.name.Equals(name)) obj.name = name;
|
||||
SetActive(obj, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj = new GameObject();
|
||||
|
||||
Reference in New Issue
Block a user