优化Legend初始化,防止出现预设下删除异常的问题

This commit is contained in:
monitor1394
2020-04-10 07:32:59 +08:00
parent 73e713802c
commit 80a946d0c6
3 changed files with 9 additions and 5 deletions

View File

@@ -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();