版本:3.7.3
1.创建空节点
2.拖入模型
3. 调整好后拖入文件资源管理器中
4.删除上面层级管理器中的节点
5.双击预制资源,添加自定义脚本
6. 场景层级管理器新建空节点,添加管理文件,用于初始化
@ccclass('HeartManager')
export class HeartManager extends Component {
@property(Prefab)
prefab:Prefab=null;
start() {
this.createHeart()
}
public createHeart(){
let npc=instantiate(this.prefab)
let position_move = new Vec3(0,0, 5)
npc.setPosition(position_move)
this.node.addChild(npc)
}
update(deltaTime: number) {
}
}