const projectPath = window.cce.project as string; const fs = window.Editor.require(‘fs’); 这两个生成地图json数据的方法为什么在1.2粒不能用了呢?
首先要感谢VisualSJ和arsen2010耐心解答,没想到官方这么尽责,cocos以后必然壮大,加油~!
已解决
1 去掉window,直接使用cce.project as string来获取项目路径。
2 直接使用require(‘fs’) 来获取fs。
3 注意这种只能在编辑器里使用,无法在游戏脚本里使用。
使用该方法可以非常方便的生成地图数据资源,点击图片中红框所示的复选框可以动态生成地图中节点的json数据。
所有子节点必需是预制体。
具体请看官方源码:
1 生成json数据
https://github.com/cocos-creator/example-3d/blob/master/physics-3d/assets/demo/simple-car/scripts/debug/MapSpawner.ts
2 根据数据往节点添加预制体
https://github.com/cocos-creator/example-3d/blob/master/physics-3d/assets/demo/simple-car/scripts/debug/MapLoaderTesing.ts



