版本: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) {
}
}
本文介绍如何在Cocos Creator 3.7.3版本中使用预制资源进行节点实例化。通过创建空节点、导入模型并调整位置后保存为预制资源,再利用脚本实例化这些资源,并设置初始位置。
3197

被折叠的 条评论
为什么被折叠?



