if (Input.GetMouseButtonDown(0))
{
Vector2 outVec;
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRect, Input.mousePosition, canvas.worldCamera, out outVec))
{
// Debug.Log("转换后的屏幕坐标: " + outVec + "鼠标坐标" + Input.mousePosition);
int idx = Random.Range(0, LeiFen_BoxPrefab.Length);
GameObject ShuiBoWenobjClone = Instantiate(LeiFen_BoxPrefab[idx]) as GameObject;
ShuiBoWenobjClone.transform.parent = LeiFen_BoxFuWuTi;
ShuiBoWenobjClone.transform.localPosition = new Vector3(0, 0, 0);
float idx1 = Random.Range(float.Parse(ConfigTest.dic["设置"]["冰裂最小值"]), float.Parse(ConfigTest.dic["设置"]["冰裂最大值"]));
ShuiBoWenobjClone.transform.localScale = new Vector3(idx1, idx1, idx1);
ShuiBoWenobjClone.GetComponent<RectTransform>().anchoredPosition = outVec;
}
}
LeiFen_BoxPrefab 是要克隆的物体
LeiFen_BoxFuWuTi 克隆物体的父物体