在项目中我需要将一个对象进行复制,于是我在代码中设置了一个绑定字段,将自己拖上去,然后
child = Instantiate<UIChiBiSelector> (this.childSelector);
child.gameObject.name = "child";if (child != null) {
child.transform.SetParent(this.transform);
child.transform.localScale = Vector3.one;
child.transform.localPosition = getChildLoc();
}
child.setPokers (pokers, samePoker, this.ps, chain, root==null?this:root, cTypes);
这里的一个逻辑是将复制出的作为自己的子级显示。于是这就产生了一个问题。由于拖放的绑定是自己,所以这个引用指向并不是库里的对象。而自己本身。这就会导致在第二次再复制时会将自己已经加了子级的对象再复制一次,这就像两个镜子对着照一样,如此往复,越往后越多,无限生长。
就在我写这个记录时,我想到了这个原因如上。之前我还以