我正在复制一个被触摸的图像。我在拖动克隆时将原始图像设置为非活动状态。
但是,我想从克隆脚本中销毁克隆图像时重新激活原始图像。
我可以在实例化它时将原始图像的引用添加到克隆中吗?我尝试使用原始搜索,GameObject original = transform.Find(transform.gameObject.name).gameObject;但我认为您找不到已停用的 GameObjects
public void OnPointerDown(PointerEventData eventData)
{
if (this.gameObject.tag != "Clone")
{
clone = Instantiate(this.gameObject) as GameObject;
clone.transform.SetParent(GameObject.FindGameObjectWithTag("Canvas").transform, false);
clone.transform.position = transform.position;
clone.transform.localScale += new Vector3(0.5F, 0.5F, 0);
clone.gameObject.tag = "Clone";
clone.gameObject.name = transform.gameObject.name;
}