我创建了27个prefeb实例,销毁时发生了奇怪的情况

3.7.2
我创建了27个prefeb实例,销毁时发生了奇怪的情况,我在预制体脚本里写了碰撞时,将预制体放入节点池,照理是哪个实例被碰撞就销毁哪个,但是奇怪的是碰撞一发生,所有27个实例都没了。
gamemanager代码:
@ccclass(‘GameManger’)

export class GameManger extends Component {

@property(Node)

public GemRoot: Node = null;

@property(Node)

public Bar: Node = null;

@property(Prefab)

public Ball: Prefab = null;

@property(Prefab)

public Gem1: Prefab = null;

@property(Prefab)

public Gem2: Prefab = null;

@property(Prefab)

public Gem3: Prefab = null;

@property(Prefab)

public Gem4: Prefab = null;

@property(Prefab)

public Gem5: Prefab = null;

@property(Prefab)

public Gem6: Prefab = null;

start() {

    this._init();

}

update(deltaTime: number) {

}

CreateBall() {

    const ball = PoolManager.instance().getNode(this.Ball, this.GemRoot);

    //ChangeAni.setPosition(pos.x, pos.y, pos.z );

}

CreateGem(x: number, y: number) {

    var gem: Prefab[] = [this.Gem1, this.Gem2, this.Gem3, this.Gem4, this.Gem5, this.Gem6];

    const i = math.randomRangeInt(0, 6);

    //const x=math.randomRangeInt(-300,300);

    const Ball = PoolManager.instance().getNode(gem[i], this.GemRoot);

    log(this.GemRoot.parent.name);

    Ball.setPosition(x, y, 0);

}

_init() {

    const balla = PoolManager.instance().getNode(this.Ball, this.GemRoot);

    balla.setPosition(0, -500, 0);

    const compo = balla.getComponent(ball);

    compo.SetSpeed();

    let i;

    for (i = 0; i < 9; i++) {

        this.CreateGem(i * 80 - 320, 520);

        this.CreateGem(i * 80 - 320, 680);

        this.CreateGem(i * 80 - 320, 360);

    }

}

}
预制体代码:
@ccclass(‘Gem’)

export class Gem extends Component {

private rgb: RigidBody2D = null;

private speed = 1;

start() {

    this.speed = 1;

    this.rgb = this.node.getComponent(RigidBody2D);

    let collider = this.getComponent(Collider2D);

    //  if (collider) {

    //      collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);

    //      // collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);

    //      // collider.on(Contact2DType.PRE_SOLVE, this.onPreSolve, this);

    //      // collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);

    //  }

    if (PhysicsSystem2D.instance) {

        PhysicsSystem2D.instance.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);

        // PhysicsSystem2D.instance.on(Contact2DType.END_CONTACT, this.onEndContact, this);

        // PhysicsSystem2D.instance.on(Contact2DType.PRE_SOLVE, this.onPreSolve, this);

        // PhysicsSystem2D.instance.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);

    }

}

onBeginContact(selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {

    //log('peng!')

    PoolManager.instance().putNode(this.node);

}

update(deltaTime: number) {

    const pos = this.node.position;

    if (pos.y < -500) {

        this.node.setPosition(pos.x, 700, 0);

    }

}

补充,节点池代码:
import { _decorator, Component, Node, Prefab, NodePool, instantiate } from ‘cc’;

const { ccclass, property } = _decorator;

interface IDictPool {

[name: string]: NodePool;

}

interface IDictPrefab {

[name: string]: Prefab;

}

@ccclass(‘PoolManager’)

export class PoolManager {

public static instance() {

    if (!this._instance) {

        this._instance = new PoolManager();

    }

    return this._instance;

}

private _dictPool: IDictPool = {};

private _dictPrefab: IDictPrefab = {};

private static _instance: PoolManager;

public getNode(prefab: Prefab, parent: Node) {

    let name = prefab.name;

    let node: Node = null;

    this._dictPrefab[name] = prefab;

    const pool = this._dictPool[name];

    if (pool) {

        if (pool.size() > 0) {

            node = pool.get();

        } else {

            node = instantiate(prefab);

        }

    } else {

        this._dictPool[name] = new NodePool();

        node = instantiate(prefab);

    }

    node.parent = parent;

    node.active = true;

    return node;

}

public putNode(node: Node) {

    let name = node.name;

    node.parent = null;

    if (!this._dictPool[name]) {

        this._dictPool[name] = new NodePool();

    }

    this._dictPool[name].put(node);

}

}