From ba76a89581df4807e595aec25d8b7e9c09729cd5 Mon Sep 17 00:00:00 2001 From: yufang <2435731537@qq.com> Date: Wed, 10 Oct 2018 10:59:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=AE=A1=E7=90=86=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E8=B5=84=E6=BA=90=E7=9A=84=E4=BF=9D=E5=AD=98=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E5=9C=BA=E6=99=AF=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- en/extension/asset-management.md | 22 +++++++++++++--------- zh/extension/asset-management.md | 16 ++++++++++------ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/en/extension/asset-management.md b/en/extension/asset-management.md index 4dcf6d702..32968e056 100644 --- a/en/extension/asset-management.md +++ b/en/extension/asset-management.md @@ -2,17 +2,21 @@ ## Manage the scene -### Save the current scene +### New scene + +you can use the `Editor.Ipc` module to create the new scene: -In the previous section [Calling Engine APIs and Project Scripts] (scene-script.md), we introduced the method of accessing the engine API and the user project script through the scenario script. After modifying the scene data, you can use the following interface to save the current scene The +`Editor.Ipc.sendToPanel('scene', 'scene:new-scene');` -`_Scene.save ()` +### Save the current scene -Where `_Scene` is a special singleton that controls the scene instance loaded in the scene editor. +After modifying the scene data, you can use the `Editor.Ipc` module to save the current scene: + +`Editor.Ipc.sendToPanel('scene', 'scene:stash-and-save');` ### Load other scenes -Our expansion packs may need to traverse multiple scenes and operate and save them sequentially. To load a new scene, use +Our expansion packs may need to traverse multiple scenes and operate and save them sequentially. In the previous section [Call the engine API and project script](scene-script.md), we introduced the method of accessing the engine API and the user project script through the scenario script. To load a new scene, use: ```js _Scene.loadSceneByUuid (uuid, function (error) { @@ -20,9 +24,9 @@ _Scene.loadSceneByUuid (uuid, function (error) { }); ``` +Where _Scene is a special singleton that controls the scene instance loaded in the scene editor.
The incoming parameter is the uuid of the scene asset, which can be obtained by the asset manager interface described below. - ## Mapping of asset URL and UUID In the Cocos Creator editor and extension, the url of the asset is shaped @@ -67,7 +71,7 @@ Editor.assetdb.import ([ ### Create an asset -A common misuse of using extended package management assets is to use the [fs module] of the Node.js (https://nodejs.org/dist/latest-v6.x/docs/api) when the extension package needs to create new assets /fs.html), so that even if the creation of the file to the `assets` directory, it can not be automatically imported by the Explorer. The correct workflow should use the `create` interface to create the asset. +A common misuse of using extended package management assets is to use the [fs module](https://nodejs.org/dist/latest-v6.x/docs/api/fs.html) of the Node.js when the extension package needs to create new assets, so that even if the creation of the file to the `assets` directory, it can not be automatically imported by the Explorer. The correct workflow should use the `create` interface to create the asset. ```js // main process or renderer process @@ -111,7 +115,7 @@ Editor.assetdb.createOrSave ('db: //assets/foo/bar/foobar.js', data, callback); ### Refresh the asset -When the asset file has been modified in the `asset` and there is no reintroduction for some reason, the asset data in the` asset` and the asset data displayed in the database are inconsistent (if the `fs` module Direct operation of the contents of the file will appear), you can manually call the asset refresh interface to re-import assets +When the asset file has been modified in the `asset` and there is no reintroduction for some reason, the asset data in the` asset` and the asset data displayed in the database are inconsistent (if the `fs` module direct operation of the contents of the file will appear), you can manually call the asset refresh interface to re-import assets ```js // main process or renderer process @@ -127,4 +131,4 @@ Editor.assetdb.move (srcUrl, destUrl); Editor.assetdb.delete ([url1, url2]); ``` -For more information on these interfaces, see [AssetDB API Main] (api / asset-db / asset-db-main.md) and [AssetDB API Renderer] (api / asset-db / asset-db-renderer.md). \ No newline at end of file +For more information on these interfaces, see [AssetDB API Main](api/asset-db/asset-db-main.md) and [AssetDB API Renderer](api/asset-db/asset-db-renderer.md). \ No newline at end of file diff --git a/zh/extension/asset-management.md b/zh/extension/asset-management.md index 43514f738..0259c5728 100644 --- a/zh/extension/asset-management.md +++ b/zh/extension/asset-management.md @@ -2,17 +2,21 @@ ## 管理场景 -### 保存当前场景 +### 新建场景 + +通过 `Editor.Ipc` 模块新建场景: -在上一节 [调用引擎 API 和项目脚本](scene-script.md) 中我们介绍了通过场景脚本访问引擎 API 和用户项目脚本的方法,在对场景数据进行修改后可以使用以下接口保存当前场景。 +`Editor.Ipc.sendToPanel('scene', 'scene:new-scene');` -`_Scene.save()` +### 保存当前场景 -其中 `_Scene` 是一个特殊的单例,用来控制场景编辑器里加载的场景实例。 +对场景数据修改完成后可以通过 `Editor.Ipc` 模块来保存当前场景: + +`Editor.Ipc.sendToPanel('scene', 'scene:stash-and-save');` ### 加载其他场景 -我们的扩展包可能需要遍历多个场景并依次操作和保存,要加载新场景,请使用 +我们的扩展包可能需要遍历多个场景并依次操作和保存,在上一节 [调用引擎 API 和项目脚本](scene-script.md) 中我们介绍了通过场景脚本访问引擎 API 和用户项目脚本的方法,要加载新场景,请使用: ```js _Scene.loadSceneByUuid(uuid, function(error) { @@ -20,9 +24,9 @@ _Scene.loadSceneByUuid(uuid, function(error) { }); ``` +其中 _Scene 是一个特殊的单例,用来控制场景编辑器里加载的场景实例。
传入的参数是场景资源的 uuid,可以通过下面介绍的资源管理器接口来获取。 - ## 资源 URL 和 UUID 的映射 在 Cocos Creator 编辑器和扩展中,资源的 url 由形如